diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c8a096b7ca7..ef6088bd6a44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,13 +57,6 @@ repos: - id: check-merge-conflict - id: check-ast - id: debug-statements - - repo: local - hooks: - - id: clvm_hex - name: .clsp.hex files - entry: ./activated.py python tools/manage_clvm.py check - language: system - pass_filenames: false - repo: local hooks: - id: chialispp diff --git a/chia/_tests/clvm/test_chialisp_deserialization.py b/chia/_tests/clvm/test_chialisp_deserialization.py index 377779788f57..33a0bad26847 100644 --- a/chia/_tests/clvm/test_chialisp_deserialization.py +++ b/chia/_tests/clvm/test_chialisp_deserialization.py @@ -1,12 +1,12 @@ from __future__ import annotations import pytest +from chia_puzzles_py.programs import CHIALISP_DESERIALISATION from chia.types.blockchain_format.program import INFINITE_COST, Program from chia.util.byte_types import hexstr_to_bytes -from chia.wallet.puzzles.load_clvm import load_clvm -DESERIALIZE_MOD = load_clvm("chialisp_deserialisation.clsp", package_or_requirement="chia.consensus.puzzles") +DESERIALIZE_MOD = Program.from_bytes(CHIALISP_DESERIALISATION) def serialized_atom_overflow(size): diff --git a/chia/_tests/clvm/test_condition_codes.py b/chia/_tests/clvm/test_condition_codes.py deleted file mode 100644 index af75f70f0b30..000000000000 --- a/chia/_tests/clvm/test_condition_codes.py +++ /dev/null @@ -1,13 +0,0 @@ -from __future__ import annotations - -import importlib_resources -from clvm.casts import int_from_bytes - -from chia.types.condition_opcodes import ConditionOpcode - - -def test_condition_codes_is_complete() -> None: - condition_codes_path = importlib_resources.files("chia.wallet.puzzles").joinpath("condition_codes.clib") - contents = condition_codes_path.read_text(encoding="utf-8") - for opcode in ConditionOpcode: - assert f"(defconstant {opcode.name} {int_from_bytes(opcode.value)})" in contents diff --git a/chia/_tests/generator/test_compression.py b/chia/_tests/generator/test_compression.py index e2b67483da9c..6ec973fa7f26 100644 --- a/chia/_tests/generator/test_compression.py +++ b/chia/_tests/generator/test_compression.py @@ -4,6 +4,14 @@ import io from typing import Any +from chia_puzzles_py.programs import ( + BLOCK_PROGRAM_ZERO, + CHIALISP_DESERIALISATION, + DECOMPRESS_COIN_SPEND_ENTRY, + DECOMPRESS_COIN_SPEND_ENTRY_WITH_PREFIX, + DECOMPRESS_PUZZLE, + ROM_BOOTSTRAP_GENERATOR, +) from chia_rs import serialized_length from clvm.serialize import sexp_from_stream from clvm.SExp import SExp @@ -15,18 +23,20 @@ from chia.util.ints import uint32 from chia.wallet.puzzles.load_clvm import load_clvm -TEST_GEN_DESERIALIZE = load_clvm( - "test_generator_deserialize.clsp", package_or_requirement="chia._tests.generator.puzzles" -) -DESERIALIZE_MOD = load_clvm("chialisp_deserialisation.clsp", package_or_requirement="chia.consensus.puzzles") +DESERIALIZE_MOD = Program.from_bytes(CHIALISP_DESERIALISATION) + +GENERATOR_MOD: Program = Program.from_bytes(ROM_BOOTSTRAP_GENERATOR) -DECOMPRESS_PUZZLE = load_clvm("decompress_puzzle.clsp", package_or_requirement="chia.full_node.puzzles") -DECOMPRESS_CSE = load_clvm("decompress_coin_spend_entry.clsp", package_or_requirement="chia.full_node.puzzles") -DECOMPRESS_CSE_WITH_PREFIX = load_clvm( - "decompress_coin_spend_entry_with_prefix.clsp", package_or_requirement="chia.full_node.puzzles" +DECOMPRESS_PUZZLE = Program.from_bytes(DECOMPRESS_PUZZLE) +DECOMPRESS_CSE = Program.from_bytes(DECOMPRESS_COIN_SPEND_ENTRY) + +DECOMPRESS_CSE_WITH_PREFIX = Program.from_bytes(DECOMPRESS_COIN_SPEND_ENTRY_WITH_PREFIX) +DECOMPRESS_BLOCK = Program.from_bytes(BLOCK_PROGRAM_ZERO) + +TEST_GEN_DESERIALIZE = load_clvm( + "test_generator_deserialize.clsp", package_or_requirement="chia._tests.generator.puzzles" ) -DECOMPRESS_BLOCK = load_clvm("block_program_zero.clsp", package_or_requirement="chia.full_node.puzzles") TEST_MULTIPLE = load_clvm( "test_multiple_generator_input_arguments.clsp", package_or_requirement="chia._tests.generator.puzzles" ) diff --git a/chia/_tests/generator/test_rom.py b/chia/_tests/generator/test_rom.py index abc1a573f6da..905284b51660 100644 --- a/chia/_tests/generator/test_rom.py +++ b/chia/_tests/generator/test_rom.py @@ -1,5 +1,6 @@ from __future__ import annotations +from chia_puzzles_py.programs import CHIALISP_DESERIALISATION, ROM_BOOTSTRAP_GENERATOR from clvm.CLVMObject import CLVMStorage from clvm_tools import binutils from clvm_tools.clvmc import compile_clvm_text @@ -13,16 +14,13 @@ from chia.types.generator_types import BlockGenerator from chia.types.spend_bundle_conditions import SpendConditions from chia.util.ints import uint32 -from chia.wallet.puzzles.load_clvm import load_clvm, load_serialized_clvm_maybe_recompile -MAX_COST = 10**15 -COST_PER_BYTE = 12000 +DESERIALIZE_MOD = Program.from_bytes(CHIALISP_DESERIALISATION) +GENERATOR_MOD: SerializedProgram = SerializedProgram.from_bytes(ROM_BOOTSTRAP_GENERATOR) -DESERIALIZE_MOD = load_clvm("chialisp_deserialisation.clsp", package_or_requirement="chia.consensus.puzzles") -GENERATOR_MOD: SerializedProgram = load_serialized_clvm_maybe_recompile( - "rom_bootstrap_generator.clsp", package_or_requirement="chia.consensus.puzzles" -) +MAX_COST = 10**15 +COST_PER_BYTE = 12000 GENERATOR_CODE = """ diff --git a/chia/_tests/pools/test_pool_puzzles_lifecycle.py b/chia/_tests/pools/test_pool_puzzles_lifecycle.py index d9b6db36995f..497ab6f0f302 100644 --- a/chia/_tests/pools/test_pool_puzzles_lifecycle.py +++ b/chia/_tests/pools/test_pool_puzzles_lifecycle.py @@ -11,7 +11,6 @@ from chia._tests.util.key_tool import KeyTool from chia.consensus.default_constants import DEFAULT_CONSTANTS from chia.pools.pool_puzzles import ( - SINGLETON_MOD_HASH, create_absorb_spend, create_p2_singleton_puzzle, create_p2_singleton_puzzle_hash, @@ -41,6 +40,7 @@ puzzle_for_pk, solution_for_conditions, ) +from chia.wallet.puzzles.singleton_top_layer import SINGLETON_MOD_HASH from chia.wallet.singleton import get_most_recent_singleton_coin_from_coin_spend """ diff --git a/chia/_tests/pools/test_pool_rpc.py b/chia/_tests/pools/test_pool_rpc.py index b5359dee101a..6fcaa6c150eb 100644 --- a/chia/_tests/pools/test_pool_rpc.py +++ b/chia/_tests/pools/test_pool_rpc.py @@ -20,7 +20,6 @@ from chia._tests.util.setup_nodes import setup_simulators_and_wallets_service from chia._tests.util.time_out_assert import time_out_assert from chia.consensus.constants import ConsensusConstants -from chia.pools.pool_puzzles import SINGLETON_LAUNCHER_HASH from chia.pools.pool_wallet_info import PoolSingletonState, PoolWalletInfo from chia.rpc.wallet_rpc_client import WalletRpcClient from chia.simulator.add_blocks_in_batches import add_blocks_in_batches @@ -36,6 +35,7 @@ from chia.util.config import load_config from chia.util.ints import uint32, uint64 from chia.wallet.derive_keys import find_authentication_sk, find_owner_sk +from chia.wallet.singleton import SINGLETON_LAUNCHER_PUZZLE_HASH as SINGLETON_LAUNCHER_HASH from chia.wallet.transaction_record import TransactionRecord from chia.wallet.util.transaction_type import TransactionType from chia.wallet.util.tx_config import DEFAULT_TX_CONFIG diff --git a/chia/_tests/util/run_block.py b/chia/_tests/util/run_block.py index dacf04137b3f..be206e93371f 100644 --- a/chia/_tests/util/run_block.py +++ b/chia/_tests/util/run_block.py @@ -5,9 +5,11 @@ from pathlib import Path from typing import Any +from chia_puzzles_py.programs import CHIALISP_DESERIALISATION from chia_rs import Coin from chia.consensus.constants import ConsensusConstants +from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.serialized_program import SerializedProgram from chia.types.blockchain_format.sized_bytes import bytes32 from chia.types.condition_opcodes import ConditionOpcode @@ -15,12 +17,9 @@ from chia.types.generator_types import BlockGenerator from chia.util.ints import uint32, uint64 from chia.wallet.cat_wallet.cat_utils import match_cat_puzzle -from chia.wallet.puzzles.load_clvm import load_serialized_clvm_maybe_recompile from chia.wallet.uncurried_puzzle import uncurry_puzzle -DESERIALIZE_MOD = load_serialized_clvm_maybe_recompile( - "chialisp_deserialisation.clsp", package_or_requirement="chia.consensus.puzzles" -) +DESERIALIZE_MOD = Program.from_bytes(CHIALISP_DESERIALISATION) @dataclass diff --git a/chia/_tests/wallet/dao_wallet/test_dao_clvm.py b/chia/_tests/wallet/dao_wallet/test_dao_clvm.py index 728b889f3890..a4a6c2120a29 100644 --- a/chia/_tests/wallet/dao_wallet/test_dao_clvm.py +++ b/chia/_tests/wallet/dao_wallet/test_dao_clvm.py @@ -17,43 +17,35 @@ from chia.util.errors import Err from chia.util.hash import std_hash from chia.util.ints import uint32, uint64 -from chia.wallet.cat_wallet.cat_utils import CAT_MOD +from chia.wallet.cat_wallet.cat_utils import CAT_MOD, CAT_MOD_HASH from chia.wallet.dao_wallet.dao_info import DAORules -from chia.wallet.dao_wallet.dao_utils import curry_singleton, get_p2_singleton_puzhash, get_treasury_puzzle -from chia.wallet.puzzles.load_clvm import load_clvm +from chia.wallet.dao_wallet.dao_utils import ( + DAO_FINISHED_STATE, + DAO_FINISHED_STATE_HASH, + DAO_LOCKUP_MOD, + DAO_PROPOSAL_MOD, + DAO_PROPOSAL_TIMER_MOD, + DAO_PROPOSAL_TIMER_MOD_HASH, + DAO_PROPOSAL_VALIDATOR_MOD, + DAO_PROPOSAL_VALIDATOR_MOD_HASH, + DAO_TREASURY_MOD, + DAO_TREASURY_MOD_HASH, + P2_SINGLETON_AGGREGATOR_MOD, + P2_SINGLETON_MOD, + SPEND_P2_SINGLETON_MOD, + curry_singleton, + get_p2_singleton_puzhash, + get_treasury_puzzle, +) +from chia.wallet.dao_wallet.dao_utils import ( + DAO_UPDATE_PROPOSAL_MOD as DAO_UPDATE_MOD, +) +from chia.wallet.singleton import SINGLETON_LAUNCHER_PUZZLE_HASH as SINGLETON_LAUNCHER_HASH +from chia.wallet.singleton import SINGLETON_TOP_LAYER_MOD as SINGLETON_MOD +from chia.wallet.singleton import SINGLETON_TOP_LAYER_MOD_HASH as SINGLETON_MOD_HASH from chia.wallet.singleton import create_singleton_puzzle_hash from chia.wallet.wallet_spend_bundle import WalletSpendBundle -CAT_MOD_HASH: bytes32 = CAT_MOD.get_tree_hash() -SINGLETON_MOD: Program = load_clvm("singleton_top_layer_v1_1.clsp") -SINGLETON_MOD_HASH: bytes32 = SINGLETON_MOD.get_tree_hash() -SINGLETON_LAUNCHER: Program = load_clvm("singleton_launcher.clsp") -SINGLETON_LAUNCHER_HASH: bytes32 = SINGLETON_LAUNCHER.get_tree_hash() -DAO_LOCKUP_MOD: Program = load_clvm("dao_lockup.clsp") -DAO_LOCKUP_MOD_HASH: bytes32 = DAO_LOCKUP_MOD.get_tree_hash() -DAO_PROPOSAL_TIMER_MOD: Program = load_clvm("dao_proposal_timer.clsp") -DAO_PROPOSAL_TIMER_MOD_HASH: bytes32 = DAO_PROPOSAL_TIMER_MOD.get_tree_hash() -DAO_PROPOSAL_MOD: Program = load_clvm("dao_proposal.clsp") -DAO_PROPOSAL_MOD_HASH: bytes32 = DAO_PROPOSAL_MOD.get_tree_hash() -DAO_PROPOSAL_VALIDATOR_MOD: Program = load_clvm("dao_proposal_validator.clsp") -DAO_PROPOSAL_VALIDATOR_MOD_HASH: bytes32 = DAO_PROPOSAL_VALIDATOR_MOD.get_tree_hash() -DAO_TREASURY_MOD: Program = load_clvm("dao_treasury.clsp") -DAO_TREASURY_MOD_HASH: bytes32 = DAO_TREASURY_MOD.get_tree_hash() -SPEND_P2_SINGLETON_MOD: Program = load_clvm("dao_spend_p2_singleton_v2.clsp") -SPEND_P2_SINGLETON_MOD_HASH: bytes32 = SPEND_P2_SINGLETON_MOD.get_tree_hash() -DAO_FINISHED_STATE: Program = load_clvm("dao_finished_state.clsp") -DAO_FINISHED_STATE_HASH: bytes32 = DAO_FINISHED_STATE.get_tree_hash() -DAO_CAT_TAIL: Program = load_clvm( - "genesis_by_coin_id_or_singleton.clsp", package_or_requirement="chia.wallet.cat_wallet.puzzles" -) -DAO_CAT_TAIL_HASH: bytes32 = DAO_CAT_TAIL.get_tree_hash() -P2_SINGLETON_MOD: Program = load_clvm("p2_singleton_via_delegated_puzzle.clsp") -P2_SINGLETON_MOD_HASH: bytes32 = P2_SINGLETON_MOD.get_tree_hash() -P2_SINGLETON_AGGREGATOR_MOD: Program = load_clvm("p2_singleton_aggregator.clsp") -P2_SINGLETON_AGGREGATOR_MOD_HASH: bytes32 = P2_SINGLETON_AGGREGATOR_MOD.get_tree_hash() -DAO_UPDATE_MOD: Program = load_clvm("dao_update_proposal.clsp") -DAO_UPDATE_MOD_HASH: bytes32 = DAO_UPDATE_MOD.get_tree_hash() - def test_finished_state() -> None: """ @@ -63,9 +55,7 @@ def test_finished_state() -> None: the lockup puzzle. """ proposal_id = Program.to("proposal_id").get_tree_hash() - singleton_struct: Program = Program.to( - (SINGLETON_MOD.get_tree_hash(), (proposal_id, SINGLETON_LAUNCHER.get_tree_hash())) - ) + singleton_struct: Program = Program.to((SINGLETON_MOD_HASH, (proposal_id, SINGLETON_LAUNCHER_HASH))) finished_inner_puz = DAO_FINISHED_STATE.curry(singleton_struct, DAO_FINISHED_STATE_HASH) finished_full_puz = SINGLETON_MOD.curry(singleton_struct, finished_inner_puz) inner_sol = Program.to([1]) @@ -93,9 +83,7 @@ def test_proposal() -> None: CAT_TAIL_HASH = Program.to("tail").get_tree_hash() treasury_id = Program.to("treasury").get_tree_hash() singleton_id = Program.to("singleton_id").get_tree_hash() - singleton_struct: Program = Program.to( - (SINGLETON_MOD.get_tree_hash(), (singleton_id, SINGLETON_LAUNCHER.get_tree_hash())) - ) + singleton_struct: Program = Program.to((SINGLETON_MOD_HASH, (singleton_id, SINGLETON_LAUNCHER_HASH))) self_destruct_time = 1000 # number of blocks oracle_spend_delay = 10 active_votes_list = [0xFADEDDAB] # are the ids of previously voted on proposals? @@ -387,9 +375,7 @@ def test_proposal_timer() -> None: CAT_TAIL_HASH = Program.to("tail").get_tree_hash() treasury_id = Program.to("treasury").get_tree_hash() singleton_id = Program.to("singleton_id").get_tree_hash() - singleton_struct: Program = Program.to( - (SINGLETON_MOD.get_tree_hash(), (singleton_id, SINGLETON_LAUNCHER.get_tree_hash())) - ) + singleton_struct: Program = Program.to((SINGLETON_MOD_HASH, (singleton_id, SINGLETON_LAUNCHER_HASH))) dao_lockup_self = DAO_LOCKUP_MOD.curry( SINGLETON_MOD_HASH, SINGLETON_LAUNCHER_HASH, @@ -482,7 +468,7 @@ def test_validator() -> None: # Setup the proposal proposal_id = Program.to("proposal_id").get_tree_hash() - proposal_struct: Program = Program.to((SINGLETON_MOD.get_tree_hash(), (proposal_id, SINGLETON_LAUNCHER_HASH))) + proposal_struct: Program = Program.to((SINGLETON_MOD_HASH, (proposal_id, SINGLETON_LAUNCHER_HASH))) CAT_TAIL_HASH = Program.to("tail").get_tree_hash() acs: Program = Program.to(1) acs_ph: bytes32 = acs.get_tree_hash() diff --git a/chia/_tests/wallet/db_wallet/test_db_graftroot.py b/chia/_tests/wallet/db_wallet/test_db_graftroot.py index 13770a6de881..1c93a8821d5b 100644 --- a/chia/_tests/wallet/db_wallet/test_db_graftroot.py +++ b/chia/_tests/wallet/db_wallet/test_db_graftroot.py @@ -10,12 +10,10 @@ from chia.types.coin_spend import make_spend from chia.types.mempool_inclusion_status import MempoolInclusionStatus from chia.util.errors import Err -from chia.wallet.puzzles.load_clvm import load_clvm +from chia.wallet.db_wallet.db_wallet_puzzles import GRAFTROOT_DL_OFFERS from chia.wallet.util.merkle_utils import build_merkle_tree, build_merkle_tree_from_binary_tree, simplify_merkle_proof from chia.wallet.wallet_spend_bundle import WalletSpendBundle -GRAFTROOT_MOD = load_clvm("graftroot_dl_offers.clsp", package_or_requirement="chia.data_layer.puzzles") - # Always returns the last value # (mod solution # @@ -46,7 +44,7 @@ async def test_graftroot(cost_logger: CostLogger) -> None: desired_key_values = ((bytes32.zeros, bytes32([1] * 32)), (bytes32([7] * 32), bytes32([8] * 32))) desired_row_hashes: list[bytes32] = [build_merkle_tree_from_binary_tree(kv)[0] for kv in desired_key_values] fake_struct: Program = Program.to((ACS_PH, NIL_PH)) - graftroot_puzzle: Program = GRAFTROOT_MOD.curry( + graftroot_puzzle: Program = GRAFTROOT_DL_OFFERS.curry( # Do everything twice to test depending on multiple singleton updates p2_conditions, [fake_struct, fake_struct], diff --git a/chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py b/chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py index 52b146dd4f48..1bed036835ce 100644 --- a/chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py +++ b/chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py @@ -12,13 +12,12 @@ from chia.types.mempool_inclusion_status import MempoolInclusionStatus from chia.util.errors import Err from chia.wallet.conditions import AssertPuzzleAnnouncement -from chia.wallet.nft_wallet.nft_puzzles import ( - NFT_METADATA_UPDATER, - NFT_TRANSFER_PROGRAM_DEFAULT, +from chia.wallet.nft_wallet.nft_puzzle_utils import ( construct_ownership_layer, create_nft_layer_puzzle_with_curry_params, metadata_to_program, ) +from chia.wallet.nft_wallet.nft_puzzles import NFT_METADATA_UPDATER, NFT_TRANSFER_PROGRAM_DEFAULT from chia.wallet.wallet_spend_bundle import WalletSpendBundle ACS = Program.to(1) diff --git a/chia/_tests/wallet/nft_wallet/test_nft_puzzles.py b/chia/_tests/wallet/nft_wallet/test_nft_puzzles.py index 4a7c40d7e7e3..589ed0846963 100644 --- a/chia/_tests/wallet/nft_wallet/test_nft_puzzles.py +++ b/chia/_tests/wallet/nft_wallet/test_nft_puzzles.py @@ -7,35 +7,34 @@ from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 from chia.wallet.nft_wallet import uncurry_nft -from chia.wallet.nft_wallet.nft_puzzles import ( +from chia.wallet.nft_wallet.nft_puzzle_utils import ( construct_ownership_layer, create_full_puzzle, create_nft_layer_puzzle_with_curry_params, recurry_nft_puzzle, ) +from chia.wallet.nft_wallet.nft_puzzles import ( + NFT_METADATA_UPDATER_HASH, + NFT_OWNERSHIP_LAYER, + NFT_STATE_LAYER_MOD, + NFT_STATE_LAYER_MOD_HASH, + NFT_TRANSFER_PROGRAM_DEFAULT, +) from chia.wallet.outer_puzzles import match_puzzle -from chia.wallet.puzzles.load_clvm import load_clvm from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import puzzle_for_pk, solution_for_conditions -from chia.wallet.uncurried_puzzle import uncurry_puzzle - -SINGLETON_MOD = load_clvm("singleton_top_layer_v1_1.clsp") -LAUNCHER_PUZZLE = load_clvm("singleton_launcher.clsp") -DID_MOD = load_clvm("did_innerpuz.clsp", package_or_requirement="chia.wallet.did_wallet.puzzles") -NFT_STATE_LAYER_MOD = load_clvm("nft_state_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles") -NFT_OWNERSHIP_LAYER = load_clvm("nft_ownership_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles") -NFT_TRANSFER_PROGRAM_DEFAULT = load_clvm( - "nft_ownership_transfer_program_one_way_claim_with_royalties.clsp", - package_or_requirement="chia.wallet.nft_wallet.puzzles", +from chia.wallet.singleton import ( + SINGLETON_LAUNCHER_PUZZLE_HASH as LAUNCHER_PUZZLE_HASH, ) -LAUNCHER_PUZZLE_HASH = LAUNCHER_PUZZLE.get_tree_hash() -NFT_STATE_LAYER_MOD_HASH = NFT_STATE_LAYER_MOD.get_tree_hash() -SINGLETON_MOD_HASH = SINGLETON_MOD.get_tree_hash() -OFFER_MOD = load_clvm("settlement_payments.clsp") +from chia.wallet.singleton import ( + SINGLETON_TOP_LAYER_MOD as SINGLETON_MOD, +) +from chia.wallet.singleton import ( + SINGLETON_TOP_LAYER_MOD_HASH, +) +from chia.wallet.trading.offer import OFFER_MOD_HASH +from chia.wallet.uncurried_puzzle import uncurry_puzzle LAUNCHER_ID = Program.to(b"launcher-id").get_tree_hash() -NFT_METADATA_UPDATER_DEFAULT = load_clvm( - "nft_metadata_updater_default.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" -) def test_nft_transfer_puzzle_hashes(seeded_random: random.Random) -> None: @@ -45,11 +44,11 @@ def test_nft_transfer_puzzle_hashes(seeded_random: random.Random) -> None: maker_did = Program.to("maker did").get_tree_hash() # maker_did_inner_hash = Program.to("maker did inner hash").get_tree_hash() metadata = [("u", ["https://www.chia.net/img/branding/chia-logo.svg"]), ("h", 0xD4584AD463139FA8C0D9F68F4B59F185)] - metadata_updater_hash = NFT_METADATA_UPDATER_DEFAULT.get_tree_hash() + metadata_updater_hash = NFT_METADATA_UPDATER_HASH # royalty_addr = maker_p2_ph royalty_pc = 2000 # basis pts nft_id = Program.to("nft id").get_tree_hash() - SINGLETON_STRUCT = Program.to((SINGLETON_MOD_HASH, (nft_id, LAUNCHER_PUZZLE_HASH))) + SINGLETON_STRUCT = Program.to((SINGLETON_TOP_LAYER_MOD_HASH, (nft_id, LAUNCHER_PUZZLE_HASH))) transfer_puz = NFT_TRANSFER_PROGRAM_DEFAULT.curry(SINGLETON_STRUCT, maker_p2_ph, royalty_pc) ownership_puz = NFT_OWNERSHIP_LAYER.curry( NFT_OWNERSHIP_LAYER.get_tree_hash(), maker_did, transfer_puz, maker_p2_puz @@ -110,7 +109,7 @@ def make_a_new_solution() -> tuple[Program, Program]: puzhash = p2_puzzle.get_tree_hash() new_did = Program.to("test").get_tree_hash() new_did_inner_hash = Program.to("fake").get_tree_hash() - trade_prices_list = [[200, OFFER_MOD.get_tree_hash()]] + trade_prices_list = [[200, OFFER_MOD_HASH]] condition_list = [[51, puzhash, 1, [puzhash]], [-10, new_did, trade_prices_list, new_did_inner_hash]] solution = Program.to([[], [], [[solution_for_conditions(condition_list)]]]) return p2_puzzle, solution @@ -121,7 +120,7 @@ def make_a_new_ownership_layer_puzzle() -> tuple[Program, Program]: innerpuz = puzzle_for_pk(pubkey) old_did = Program.to("test_2").get_tree_hash() nft_id = Program.to("nft_id") - SINGLETON_STRUCT = Program.to((SINGLETON_MOD_HASH, (nft_id, LAUNCHER_PUZZLE_HASH))) + SINGLETON_STRUCT = Program.to((SINGLETON_TOP_LAYER_MOD_HASH, (nft_id, LAUNCHER_PUZZLE_HASH))) curried_tp = NFT_TRANSFER_PROGRAM_DEFAULT.curry(SINGLETON_STRUCT, innerpuz.get_tree_hash(), 2000) curried_inner = innerpuz curried_ownership_layer = construct_ownership_layer(old_did, curried_tp, curried_inner) @@ -130,7 +129,7 @@ def make_a_new_ownership_layer_puzzle() -> tuple[Program, Program]: def make_a_new_nft_puzzle(curried_ownership_layer: Program, metadata: Program) -> Program: curried_state_layer = NFT_STATE_LAYER_MOD.curry( - NFT_STATE_LAYER_MOD_HASH, metadata, NFT_METADATA_UPDATER_DEFAULT.get_tree_hash(), curried_ownership_layer + NFT_STATE_LAYER_MOD_HASH, metadata, NFT_METADATA_UPDATER_HASH, curried_ownership_layer ) return curried_state_layer @@ -151,12 +150,12 @@ def test_transfer_puzzle_builder() -> None: sp2_puzzle, solution = make_a_new_solution() p2_puzzle, ownership_puzzle = make_a_new_ownership_layer_puzzle() clvm_nft_puzzle = create_nft_layer_puzzle_with_curry_params( - Program.to(metadata), NFT_METADATA_UPDATER_DEFAULT.get_tree_hash(), ownership_puzzle + Program.to(metadata), NFT_METADATA_UPDATER_HASH, ownership_puzzle ) puzzle = create_full_puzzle( Program.to(["singleton_id"]).get_tree_hash(), Program.to(metadata), - NFT_METADATA_UPDATER_DEFAULT.get_tree_hash(), + NFT_METADATA_UPDATER_HASH, ownership_puzzle, ) clvm_puzzle_hash = get_updated_nft_puzzle(clvm_nft_puzzle, solution.at("rrf")) @@ -166,7 +165,5 @@ def test_transfer_puzzle_builder() -> None: assert unft.inner_puzzle == ownership_puzzle assert unft.p2_puzzle == p2_puzzle ol_puzzle = recurry_nft_puzzle(unft, solution, sp2_puzzle) - nft_puzzle = create_nft_layer_puzzle_with_curry_params( - Program.to(metadata), NFT_METADATA_UPDATER_DEFAULT.get_tree_hash(), ol_puzzle - ) + nft_puzzle = create_nft_layer_puzzle_with_curry_params(Program.to(metadata), NFT_METADATA_UPDATER_HASH, ol_puzzle) assert clvm_puzzle_hash == nft_puzzle.get_tree_hash() diff --git a/chia/_tests/wallet/test_singleton.py b/chia/_tests/wallet/test_singleton.py index af6d65d3eec0..f73abd3c120b 100644 --- a/chia/_tests/wallet/test_singleton.py +++ b/chia/_tests/wallet/test_singleton.py @@ -7,16 +7,8 @@ from chia.types.blockchain_format.sized_bytes import bytes32 from chia.util.condition_tools import parse_sexp_to_conditions from chia.wallet.conditions import AssertPuzzleAnnouncement -from chia.wallet.puzzles.load_clvm import load_clvm - -SINGLETON_MOD = load_clvm("singleton_top_layer.clsp") -LAUNCHER_PUZZLE = load_clvm("singleton_launcher.clsp") -P2_SINGLETON_MOD = load_clvm("p2_singleton.clsp") -POOL_MEMBER_MOD = load_clvm("pool_member_innerpuz.clsp", package_or_requirement="chia.pools.puzzles") -POOL_WAITINGROOM_MOD = load_clvm("pool_waitingroom_innerpuz.clsp", package_or_requirement="chia.pools.puzzles") - -LAUNCHER_PUZZLE_HASH = LAUNCHER_PUZZLE.get_tree_hash() -SINGLETON_MOD_HASH = SINGLETON_MOD.get_tree_hash() +from chia.wallet.puzzles.singleton_top_layer import P2_SINGLETON_MOD, SINGLETON_MOD, SINGLETON_MOD_HASH +from chia.wallet.puzzles.singleton_top_layer import SINGLETON_LAUNCHER_HASH as LAUNCHER_PUZZLE_HASH LAUNCHER_ID = Program.to(b"launcher-id").get_tree_hash() POOL_REWARD_PREFIX_MAINNET = bytes32.fromhex("ccd5bb71183532bff220ba46c268991a00000000000000000000000000000000") diff --git a/chia/_tests/wallet/test_singleton_lifecycle_fast.py b/chia/_tests/wallet/test_singleton_lifecycle_fast.py index 9a202225bd6d..281e406c0c85 100644 --- a/chia/_tests/wallet/test_singleton_lifecycle_fast.py +++ b/chia/_tests/wallet/test_singleton_lifecycle_fast.py @@ -8,6 +8,8 @@ from chia._tests.clvm.coin_store import BadSpendBundleError, CoinStore, CoinTimestamp from chia.consensus.default_constants import DEFAULT_CONSTANTS +from chia.pools.pool_puzzles import POOL_MEMBER_MOD +from chia.pools.pool_puzzles import POOL_WAITING_ROOM_MOD as POOL_WAITINGROOM_MOD from chia.types.blockchain_format.coin import Coin from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.serialized_program import SerializedProgram @@ -16,19 +18,16 @@ from chia.types.condition_opcodes import ConditionOpcode from chia.util.ints import uint32, uint64 from chia.wallet.conditions import AssertCoinAnnouncement -from chia.wallet.puzzles.load_clvm import load_clvm +from chia.wallet.puzzles.singleton_top_layer import ( + P2_SINGLETON_OR_DELAYED_MOD as P2_SINGLETON_MOD, +) +from chia.wallet.puzzles.singleton_top_layer import P2_SINGLETON_OR_DELAYED_MOD_HASH as P2_SINGLETON_MOD_HASH +from chia.wallet.puzzles.singleton_top_layer import SINGLETON_LAUNCHER, SINGLETON_MOD, SINGLETON_MOD_HASH +from chia.wallet.puzzles.singleton_top_layer import SINGLETON_LAUNCHER_HASH as LAUNCHER_PUZZLE_HASH from chia.wallet.util.debug_spend_bundle import debug_spend_bundle from chia.wallet.wallet_spend_bundle import WalletSpendBundle -SINGLETON_MOD = load_clvm("singleton_top_layer.clsp") -LAUNCHER_PUZZLE = load_clvm("singleton_launcher.clsp") -P2_SINGLETON_MOD = load_clvm("p2_singleton_or_delayed_puzhash.clsp") -POOL_MEMBER_MOD = load_clvm("pool_member_innerpuz.clsp", package_or_requirement="chia.pools.puzzles") -POOL_WAITINGROOM_MOD = load_clvm("pool_waitingroom_innerpuz.clsp", package_or_requirement="chia.pools.puzzles") - -LAUNCHER_PUZZLE_HASH = LAUNCHER_PUZZLE.get_tree_hash() -SINGLETON_MOD_HASH = SINGLETON_MOD.get_tree_hash() -P2_SINGLETON_MOD_HASH = P2_SINGLETON_MOD.get_tree_hash() +LAUNCHER_PUZZLE = SINGLETON_LAUNCHER 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() @@ -386,7 +385,7 @@ def claim_p2_singleton( p2_singleton_puzzle, p2_singleton_spend_type="claim-p2-nft", singleton_inner_puzzle_hash=inner_puzzle_hash, - p2_singleton_coin_name=p2_singleton_coin_name, + p2_singleton_coin_name=bytes32(p2_singleton_coin_name), ) p2_singleton_coin_spend = make_spend( p2_singleton_coin, SerializedProgram.from_program(p2_singleton_puzzle), p2_singleton_solution diff --git a/chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py b/chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py index c72858e766f4..c4eff1578844 100644 --- a/chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py +++ b/chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py @@ -30,14 +30,14 @@ construct_exigent_metadata_layer, create_covenant_layer, create_did_tp, + create_revocation_layer, create_std_parent_morpher, - create_viral_backdoor, match_covenant_layer, match_did_tp, - match_viral_backdoor, + match_revocation_layer, solve_covenant_layer, solve_did_tp, - solve_viral_backdoor, + solve_revocation_layer, ) from chia.wallet.wallet_spend_bundle import WalletSpendBundle @@ -311,13 +311,13 @@ async def test_did_tp(cost_logger: CostLogger) -> None: @pytest.mark.anyio -async def test_viral_backdoor(cost_logger: CostLogger) -> None: +async def test_revocation_layer(cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, client): # Setup and farm the puzzle hidden_puzzle: Program = Program.to((1, [[61, 1]])) # assert a coin announcement that the solution tells us hidden_puzzle_hash: bytes32 = hidden_puzzle.get_tree_hash() - p2_either_puzzle: Program = create_viral_backdoor(hidden_puzzle_hash, ACS_PH) - assert match_viral_backdoor(uncurry_puzzle(p2_either_puzzle)) == (hidden_puzzle_hash, ACS_PH) + p2_either_puzzle: Program = create_revocation_layer(hidden_puzzle_hash, ACS_PH) + assert match_revocation_layer(uncurry_puzzle(p2_either_puzzle)) == (hidden_puzzle_hash, ACS_PH) await sim.farm_block(p2_either_puzzle.get_tree_hash()) p2_either_coin: Coin = ( @@ -333,7 +333,7 @@ async def test_viral_backdoor(cost_logger: CostLogger) -> None: make_spend( p2_either_coin, p2_either_puzzle, - solve_viral_backdoor( + solve_revocation_layer( ACS, Program.to(None), hidden=True, @@ -352,7 +352,7 @@ async def test_viral_backdoor(cost_logger: CostLogger) -> None: make_spend( p2_either_coin, p2_either_puzzle, - solve_viral_backdoor( + solve_revocation_layer( hidden_puzzle, Program.to(bytes32.zeros), hidden=True, @@ -366,7 +366,7 @@ async def test_viral_backdoor(cost_logger: CostLogger) -> None: # Spend the inner puzzle brick_hash: bytes32 = bytes32.zeros - wrapped_brick_hash: bytes32 = create_viral_backdoor( + wrapped_brick_hash: bytes32 = create_revocation_layer( hidden_puzzle_hash, brick_hash, ).get_tree_hash() @@ -378,7 +378,7 @@ async def test_viral_backdoor(cost_logger: CostLogger) -> None: make_spend( p2_either_coin, p2_either_puzzle, - solve_viral_backdoor( + solve_revocation_layer( ACS, Program.to([[51, brick_hash, 0]]), ), diff --git a/chia/consensus/puzzles/__init__.py b/chia/consensus/puzzles/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/chia/consensus/puzzles/chialisp_deserialisation.clsp b/chia/consensus/puzzles/chialisp_deserialisation.clsp deleted file mode 100644 index 4bbf49a2fba8..000000000000 --- a/chia/consensus/puzzles/chialisp_deserialisation.clsp +++ /dev/null @@ -1,69 +0,0 @@ -;; this code is included in the ROM. Unfortunately, it has a problem that limits -;; its usefulness: it is incapable of deserializing atoms with length longer than -;; 8191 = 0x1fff. -;; -;; Because this code is included in the ROM, fixing the bug would be a hard fork -;; so we're rather stuck with this bug. We recommend simply using a local version -;; of this code when necessary. - -(mod (input) - - (defconstant MAX_SINGLE_BYTE 0x7F) - (defconstant MAX_TWO_BYTE 0xbf) - (defconstant MAX_THREE_BYTE 0xdf) - (defconstant MAX_FOUR_BYTE 0xef) - (defconstant MAX_FIVE_BYTE 0xf7) - (defconstant MAX_SIX_BYTE 0xfb) - (defconstant CONS_BOX_MARKER 0xFF) - - (defun sexp_from_stream (input_stream) - (if (= (substr input_stream 0 1) CONS_BOX_MARKER) - (cons_sexp_from_stream (sexp_from_stream (substr input_stream 1))) - (atom_from_stream (substr input_stream 1) (substr input_stream 0 1)) - ) - ) - - (defun cons_sexp_from_stream (left_sexp_with_input) - (cons_return (f left_sexp_with_input) (sexp_from_stream (f (r left_sexp_with_input)))) - ) - - (defun cons_return (left_sexp right_sexp_with_input) - (list (c left_sexp (f right_sexp_with_input)) (f (r right_sexp_with_input))) - ) - - (defun atom_from_stream (input_file input_bits) - (if (= input_bits (quote 0x80)) - (list () input_file) - (if (>s input_bits MAX_SINGLE_BYTE) - (atom_from_stream_part_two (get_bitcount input_bits input_file)) - (list input_bits input_file) - ) - ) - ) - - ; Note that we reject any serialized atom here with more than 3 bytes of - ; encoded length prefix, even though the Rust and Python CLVM interpreters - ; and deserializers support more. - ; This allows 5 + 8 = 13 bits = 8191-byte atoms - ; Also note that this does not limit intermediate atom length. Those limits - ; are implemented in the clvm interpreters theselves - (defun-inline get_bitcount (input_bits input_file) - (if (>s input_bits MAX_TWO_BYTE) - (if (>s input_bits MAX_THREE_BYTE) - (x) - ;three byte length prefix - (list (concat (logand (quote 0x1f) input_bits) (substr input_file 0 1)) (substr input_file 1)) - ) - ;two byte length prefix - (list (logand (quote 0x3f) input_bits) input_file) - ) - ) - - (defun atom_from_stream_part_two ((size_to_read input_file)) - (list (substr input_file 0 size_to_read) (substr input_file size_to_read)) - ) - - ; main - (f (sexp_from_stream input)) - -) diff --git a/chia/consensus/puzzles/chialisp_deserialisation.clsp.hex b/chia/consensus/puzzles/chialisp_deserialisation.clsp.hex deleted file mode 100644 index 8d00f01d9fc6..000000000000 --- a/chia/consensus/puzzles/chialisp_deserialisation.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff05ffff02ff3effff04ff02ffff04ff05ff8080808080ffff04ffff01ffffff81ff7fff81df81bfffffff02ffff03ffff09ff0bffff01818080ffff01ff04ff80ffff04ff05ff808080ffff01ff02ffff03ffff0aff0bff1880ffff01ff02ff1affff04ff02ffff04ffff02ffff03ffff0aff0bff1c80ffff01ff02ffff03ffff0aff0bff1480ffff01ff0880ffff01ff04ffff0effff18ffff011fff0b80ffff0cff05ff80ffff01018080ffff04ffff0cff05ffff010180ff80808080ff0180ffff01ff04ffff18ffff013fff0b80ffff04ff05ff80808080ff0180ff80808080ffff01ff04ff0bffff04ff05ff80808080ff018080ff0180ff04ffff0cff15ff80ff0980ffff04ffff0cff15ff0980ff808080ffff04ffff04ff05ff1380ffff04ff2bff808080ffff02ff16ffff04ff02ffff04ff09ffff04ffff02ff3effff04ff02ffff04ff15ff80808080ff8080808080ff02ffff03ffff09ffff0cff05ff80ffff010180ff1080ffff01ff02ff2effff04ff02ffff04ffff02ff3effff04ff02ffff04ffff0cff05ffff010180ff80808080ff80808080ffff01ff02ff12ffff04ff02ffff04ffff0cff05ffff010180ffff04ffff0cff05ff80ffff010180ff808080808080ff0180ff018080 diff --git a/chia/consensus/puzzles/rom_bootstrap_generator.clsp b/chia/consensus/puzzles/rom_bootstrap_generator.clsp deleted file mode 100644 index 52fbbbbbaf6a..000000000000 --- a/chia/consensus/puzzles/rom_bootstrap_generator.clsp +++ /dev/null @@ -1,37 +0,0 @@ -(mod (block_decompresser_program (historical_blocks_tree)) - - (defconstant local_deserialize_mod - ;; this monstrosity is the assembly output of `chialisp_deserialisation.clsp` - ;; it's pasted in here because the compiler doesn't yet support nested `mod` - ;; my apologies -- RK - - (a (q 5 (a 62 (c 2 (c 5 ())))) - (c (q ((-1 . 127) -33 . -65) ((a (i (= 11 (q . -128)) (q 4 () (c 5 ())) (q 2 (i (>s 11 24) (q 2 26 (c 2 (c (a (i (>s 11 28) (q 2 (i (>s 11 20) (q 8) (q 4 (concat (logand (q . 31) 11) (substr 5 () (q . 1))) (c (substr 5 (q . 1)) ()))) 1) (q 4 (logand (q . 63) 11) (c 5 ()))) 1) ()))) (q 4 11 (c 5 ()))) 1)) 1) 4 (substr 21 () 9) (c (substr 21 9) ())) (c (c 5 19) (c 43 ())) (a 22 (c 2 (c 9 (c (a 62 (c 2 (c 21 ()))) ())))) 2 (i (= (substr 5 () (q . 1)) 16) (q 2 46 (c 2 (c (a 62 (c 2 (c (substr 5 (q . 1)) ()))) ()))) (q 2 18 (c 2 (c (substr 5 (q . 1)) (c (substr 5 () (q . 1)) ()))))) 1) - 1)) - ) - - (defun sha256tree - (TREE) - (if (l TREE) - (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE))) - (sha256 1 TREE) - ) - ) - - (defun process_coin_spend ((parent puzzle amount solution . spend_level_extras)) - (c parent (c (sha256tree puzzle) (c amount (c (a puzzle solution) spend_level_extras)))) - ) - - (defun recurse (coin_spends) - (if coin_spends - (c (process_coin_spend (f coin_spends)) (recurse (r coin_spends))) - 0 - ) - ) - - (defun process-decompressor ((coin_spends . block-level-extras)) - (c (recurse coin_spends) block-level-extras) - ) - -(process-decompressor (a block_decompresser_program (list local_deserialize_mod historical_blocks_tree)))) -) diff --git a/chia/consensus/puzzles/rom_bootstrap_generator.clsp.hex b/chia/consensus/puzzles/rom_bootstrap_generator.clsp.hex deleted file mode 100644 index 2cb8d45c81da..000000000000 --- a/chia/consensus/puzzles/rom_bootstrap_generator.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ff0cffff04ff02ffff04ffff02ff05ffff04ff08ffff04ff13ff80808080ff80808080ffff04ffff01ffffff02ffff01ff05ffff02ff3effff04ff02ffff04ff05ff8080808080ffff04ffff01ffffff81ff7fff81df81bfffffff02ffff03ffff09ff0bffff01818080ffff01ff04ff80ffff04ff05ff808080ffff01ff02ffff03ffff0aff0bff1880ffff01ff02ff1affff04ff02ffff04ffff02ffff03ffff0aff0bff1c80ffff01ff02ffff03ffff0aff0bff1480ffff01ff0880ffff01ff04ffff0effff18ffff011fff0b80ffff0cff05ff80ffff01018080ffff04ffff0cff05ffff010180ff80808080ff0180ffff01ff04ffff18ffff013fff0b80ffff04ff05ff80808080ff0180ff80808080ffff01ff04ff0bffff04ff05ff80808080ff018080ff0180ff04ffff0cff15ff80ff0980ffff04ffff0cff15ff0980ff808080ffff04ffff04ff05ff1380ffff04ff2bff808080ffff02ff16ffff04ff02ffff04ff09ffff04ffff02ff3effff04ff02ffff04ff15ff80808080ff8080808080ff02ffff03ffff09ffff0cff05ff80ffff010180ff1080ffff01ff02ff2effff04ff02ffff04ffff02ff3effff04ff02ffff04ffff0cff05ffff010180ff80808080ff80808080ffff01ff02ff12ffff04ff02ffff04ffff0cff05ffff010180ffff04ffff0cff05ff80ffff010180ff808080808080ff0180ff018080ff04ffff02ff16ffff04ff02ffff04ff09ff80808080ff0d80ffff04ff09ffff04ffff02ff1effff04ff02ffff04ff15ff80808080ffff04ff2dffff04ffff02ff15ff5d80ff7d80808080ffff02ffff03ff05ffff01ff04ffff02ff0affff04ff02ffff04ff09ff80808080ffff02ff16ffff04ff02ffff04ff0dff8080808080ff8080ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/data_layer/data_layer_wallet.py b/chia/data_layer/data_layer_wallet.py index a2c6dc28c1ea..c0e3aacb6f80 100644 --- a/chia/data_layer/data_layer_wallet.py +++ b/chia/data_layer/data_layer_wallet.py @@ -35,7 +35,6 @@ ACS_MU, ACS_MU_PH, GRAFTROOT_DL_OFFERS, - SINGLETON_LAUNCHER, create_graftroot_offer_puz, create_host_fullpuz, create_host_layer_puzzle, @@ -50,7 +49,7 @@ from chia.wallet.outer_puzzles import AssetType from chia.wallet.payment import Payment from chia.wallet.puzzle_drivers import PuzzleInfo, Solver -from chia.wallet.puzzles.singleton_top_layer_v1_1 import SINGLETON_LAUNCHER_HASH +from chia.wallet.singleton import SINGLETON_LAUNCHER_PUZZLE, SINGLETON_LAUNCHER_PUZZLE_HASH from chia.wallet.trading.offer import NotarizedPayment, Offer from chia.wallet.transaction_record import TransactionRecord from chia.wallet.util.compute_memos import compute_memos @@ -182,7 +181,7 @@ async def create_new_dl_wallet(cls, wallet_state_manager: WalletStateManager) -> @staticmethod async def match_dl_launcher(launcher_spend: CoinSpend) -> tuple[bool, Optional[bytes32]]: # Sanity check it's a launcher - if launcher_spend.puzzle_reveal.to_program() != SINGLETON_LAUNCHER: + if launcher_spend.puzzle_reveal.to_program() != SINGLETON_LAUNCHER_PUZZLE: return False, None # Let's make sure the solution looks how we expect it to @@ -210,7 +209,7 @@ async def get_launcher_coin_state(self, launcher_id: bytes32, peer: WSChiaConnec if len(coin_states) == 0: raise LauncherCoinNotFoundError(f"Launcher ID {launcher_id} is not a valid coin") - if coin_states[0].coin.puzzle_hash != SINGLETON_LAUNCHER.get_tree_hash(): + if coin_states[0].coin.puzzle_hash != SINGLETON_LAUNCHER_PUZZLE_HASH: raise ValueError(f"Coin with ID {launcher_id} is not a singleton launcher") if coin_states[0].created_height is None: raise ValueError(f"Launcher with ID {launcher_id} has not been created (maybe reorged)") @@ -313,7 +312,7 @@ async def generate_new_reporter( raise ValueError("Not enough coins to create new data layer singleton") launcher_parent: Coin = next(iter(coins)) - launcher_coin: Coin = Coin(launcher_parent.name(), SINGLETON_LAUNCHER.get_tree_hash(), uint64(1)) + launcher_coin: Coin = Coin(launcher_parent.name(), SINGLETON_LAUNCHER_PUZZLE_HASH, uint64(1)) inner_puzzle: Program = await self.standard_wallet.get_puzzle( new=not action_scope.config.tx_config.reuse_puzhash @@ -328,7 +327,7 @@ async def generate_new_reporter( await self.standard_wallet.generate_signed_transaction( amount=uint64(1), - puzzle_hash=SINGLETON_LAUNCHER.get_tree_hash(), + puzzle_hash=SINGLETON_LAUNCHER_PUZZLE_HASH, action_scope=action_scope, fee=fee, origin_id=launcher_parent.name(), @@ -339,7 +338,7 @@ async def generate_new_reporter( launcher_cs: CoinSpend = CoinSpend( launcher_coin, - SerializedProgram.from_program(SINGLETON_LAUNCHER), + SerializedProgram.from_program(SINGLETON_LAUNCHER_PUZZLE), SerializedProgram.from_program(genesis_launcher_solution), ) launcher_sb = WalletSpendBundle([launcher_cs], G2Element()) @@ -998,7 +997,7 @@ async def get_puzzle_info(self, launcher_id: bytes32) -> PuzzleInfo: { "type": AssetType.SINGLETON.value, "launcher_id": "0x" + launcher_id.hex(), - "launcher_ph": "0x" + SINGLETON_LAUNCHER_HASH.hex(), + "launcher_ph": "0x" + SINGLETON_LAUNCHER_PUZZLE_HASH.hex(), "also": { "type": AssetType.METADATA.value, "metadata": f"(0x{record.root} . ())", diff --git a/chia/full_node/mempool_check_conditions.py b/chia/full_node/mempool_check_conditions.py index bf9a2a9a9f65..b02a5d85db61 100644 --- a/chia/full_node/mempool_check_conditions.py +++ b/chia/full_node/mempool_check_conditions.py @@ -3,6 +3,7 @@ import logging from typing import Optional +from chia_puzzles_py.programs import CHIALISP_DESERIALISATION from chia_rs import ( get_flags_for_height_and_constants, run_chia_program, @@ -20,11 +21,9 @@ from chia.util.condition_tools import conditions_for_solution from chia.util.errors import Err from chia.util.ints import uint32, uint64 -from chia.wallet.puzzles.load_clvm import load_serialized_clvm_maybe_recompile -DESERIALIZE_MOD = load_serialized_clvm_maybe_recompile( - "chialisp_deserialisation.clsp", package_or_requirement="chia.consensus.puzzles" -) +DESERIALIZE_MOD = Program.from_bytes(CHIALISP_DESERIALISATION) + log = logging.getLogger(__name__) diff --git a/chia/full_node/puzzles/__init__.py b/chia/full_node/puzzles/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/chia/full_node/puzzles/block_program_zero.clsp b/chia/full_node/puzzles/block_program_zero.clsp deleted file mode 100644 index 35f16816e078..000000000000 --- a/chia/full_node/puzzles/block_program_zero.clsp +++ /dev/null @@ -1,14 +0,0 @@ - -; TODO convert generators arg to list of generators - -(mod (decompress_puzzle decompress_coin_spend_entry start end compressed_cses deserialize gen_list reserved_arg) - - (defun decompress_cses (decompress_puzzle decompress_coin_spend_entry cses deserialize puzzle_prefix) - (if cses - (c (a decompress_coin_spend_entry (list deserialize decompress_puzzle puzzle_prefix (f cses))) - (decompress_cses decompress_puzzle decompress_coin_spend_entry (r cses) deserialize puzzle_prefix )) - ()) ) - - (list (decompress_cses decompress_puzzle decompress_coin_spend_entry compressed_cses deserialize (substr (f gen_list) start end))) - -) diff --git a/chia/full_node/puzzles/block_program_zero.clsp.hex b/chia/full_node/puzzles/block_program_zero.clsp.hex deleted file mode 100644 index fe9a4adc0816..000000000000 --- a/chia/full_node/puzzles/block_program_zero.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff02ff02ffff04ff02ffff04ff05ffff04ff0bffff04ff5fffff04ff81bfffff04ffff0cff82027fff17ff2f80ff8080808080808080ff8080ffff04ffff01ff02ffff03ff17ffff01ff04ffff02ff0bffff04ff2fffff04ff05ffff04ff5fffff04ff27ff808080808080ffff02ff02ffff04ff02ffff04ff05ffff04ff0bffff04ff37ffff04ff2fffff04ff5fff808080808080808080ff8080ff0180ff018080 diff --git a/chia/full_node/puzzles/decompress_coin_spend_entry.clsp b/chia/full_node/puzzles/decompress_coin_spend_entry.clsp deleted file mode 100644 index 440c4933ccae..000000000000 --- a/chia/full_node/puzzles/decompress_coin_spend_entry.clsp +++ /dev/null @@ -1,5 +0,0 @@ -(mod (deserialize decompress_puzzle puzzle_prefix suffix cse) - - ; decompress a single compressed standard transaction - (c (f cse) (c (a decompress_puzzle (list deserialize puzzle_prefix (f (f (r cse))) suffix)) (c (f (r (f cse))) (r (f (r cse)))))) -) diff --git a/chia/full_node/puzzles/decompress_coin_spend_entry.clsp.hex b/chia/full_node/puzzles/decompress_coin_spend_entry.clsp.hex deleted file mode 100644 index 44f27dd3add7..000000000000 --- a/chia/full_node/puzzles/decompress_coin_spend_entry.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff04ff4fffff04ffff02ff05ffff04ff02ffff04ff0bffff04ff82012fffff04ff17ff808080808080ffff04ff82014fff8201af808080 diff --git a/chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp b/chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp deleted file mode 100644 index a0539842acfc..000000000000 --- a/chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp +++ /dev/null @@ -1,7 +0,0 @@ -(mod (deserialize decompress_puzzle puzzle_prefix cse) - - ; decompress a single compressed standard transaction - - (c (f (f cse)) (c (a decompress_puzzle (list deserialize puzzle_prefix (f (f (r cse))) (q . 0xff018080))) (c (f (r (f cse))) (r (f (r cse)))))) - -) diff --git a/chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp.hex b/chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp.hex deleted file mode 100644 index 3837b9446ef7..000000000000 --- a/chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff04ff47ffff04ffff02ff05ffff04ff02ffff04ff0bffff04ff8197ffff01ff84ff0180808080808080ffff04ff81a7ff81d7808080 diff --git a/chia/full_node/puzzles/decompress_puzzle.clsp b/chia/full_node/puzzles/decompress_puzzle.clsp deleted file mode 100644 index df035b6a0f0a..000000000000 --- a/chia/full_node/puzzles/decompress_puzzle.clsp +++ /dev/null @@ -1,6 +0,0 @@ -(mod (deserialize puzzle_prefix pubkey suffix) - - (a deserialize (list (concat puzzle_prefix pubkey suffix))) - -) - diff --git a/chia/full_node/puzzles/decompress_puzzle.clsp.hex b/chia/full_node/puzzles/decompress_puzzle.clsp.hex deleted file mode 100644 index 4563bc8aff88..000000000000 --- a/chia/full_node/puzzles/decompress_puzzle.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ff02ffff04ffff0eff05ff0bff1780ff808080 diff --git a/chia/pools/pool_puzzles.py b/chia/pools/pool_puzzles.py index 0005b0d6053f..e0226c76a91f 100644 --- a/chia/pools/pool_puzzles.py +++ b/chia/pools/pool_puzzles.py @@ -3,6 +3,14 @@ import logging from typing import Optional +from chia_puzzles_py.programs import ( + P2_SINGLETON_OR_DELAYED_PUZHASH, + P2_SINGLETON_OR_DELAYED_PUZHASH_HASH, + POOL_MEMBER_INNERPUZ, + POOL_MEMBER_INNERPUZ_HASH, + POOL_WAITINGROOM_INNERPUZ, + POOL_WAITINGROOM_INNERPUZ_HASH, +) from chia_rs import G1Element from clvm.casts import int_to_bytes @@ -15,29 +23,27 @@ from chia.types.blockchain_format.sized_bytes import bytes32 from chia.types.coin_spend import CoinSpend, compute_additions from chia.util.ints import uint32, uint64 -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile -from chia.wallet.puzzles.singleton_top_layer import puzzle_for_singleton +from chia.wallet.puzzles.singleton_top_layer import ( + SINGLETON_LAUNCHER_HASH, + SINGLETON_MOD, + SINGLETON_MOD_HASH, + puzzle_for_singleton, +) from chia.wallet.util.curry_and_treehash import calculate_hash_of_quoted_mod_hash, curry_and_treehash, shatree_atom log = logging.getLogger(__name__) # "Full" is the outer singleton, with the inner puzzle filled in -SINGLETON_MOD = load_clvm_maybe_recompile("singleton_top_layer.clsp") -POOL_WAITING_ROOM_MOD = load_clvm_maybe_recompile( - "pool_waitingroom_innerpuz.clsp", package_or_requirement="chia.pools.puzzles" -) -POOL_MEMBER_MOD = load_clvm_maybe_recompile("pool_member_innerpuz.clsp", package_or_requirement="chia.pools.puzzles") -P2_SINGLETON_MOD = load_clvm_maybe_recompile("p2_singleton_or_delayed_puzhash.clsp") +POOL_WAITING_ROOM_MOD = Program.from_bytes(POOL_WAITINGROOM_INNERPUZ) +POOL_MEMBER_MOD = Program.from_bytes(POOL_MEMBER_INNERPUZ) +P2_SINGLETON_MOD = Program.from_bytes(P2_SINGLETON_OR_DELAYED_PUZHASH) POOL_OUTER_MOD = SINGLETON_MOD -POOL_MEMBER_HASH = POOL_MEMBER_MOD.get_tree_hash() -POOL_WAITING_ROOM_HASH = POOL_WAITING_ROOM_MOD.get_tree_hash() -P2_SINGLETON_HASH = P2_SINGLETON_MOD.get_tree_hash() +POOL_MEMBER_HASH = bytes32(POOL_MEMBER_INNERPUZ_HASH) +POOL_WAITING_ROOM_HASH = bytes32(POOL_WAITINGROOM_INNERPUZ_HASH) +P2_SINGLETON_HASH = bytes32(P2_SINGLETON_OR_DELAYED_PUZHASH_HASH) P2_SINGLETON_HASH_QUOTED = calculate_hash_of_quoted_mod_hash(P2_SINGLETON_HASH) -POOL_OUTER_MOD_HASH = POOL_OUTER_MOD.get_tree_hash() -SINGLETON_LAUNCHER = load_clvm_maybe_recompile("singleton_launcher.clsp") -SINGLETON_LAUNCHER_HASH = SINGLETON_LAUNCHER.get_tree_hash() +POOL_OUTER_MOD_HASH = SINGLETON_MOD_HASH SINGLETON_LAUNCHER_HASH_TREE_HASH = shatree_atom(SINGLETON_LAUNCHER_HASH) -SINGLETON_MOD_HASH = POOL_OUTER_MOD_HASH SINGLETON_MOD_HASH_HASH = Program.to(SINGLETON_MOD_HASH).get_tree_hash() diff --git a/chia/pools/pool_wallet.py b/chia/pools/pool_wallet.py index 17c5edb81361..12534c0572d6 100644 --- a/chia/pools/pool_wallet.py +++ b/chia/pools/pool_wallet.py @@ -10,7 +10,6 @@ from chia.pools.pool_config import PoolWalletConfig, load_pool_config, update_pool_config from chia.pools.pool_puzzles import ( - SINGLETON_LAUNCHER, create_absorb_spend, create_full_puzzle, create_pooling_inner_puzzle, @@ -45,6 +44,7 @@ from chia.util.ints import uint32, uint64, uint128 from chia.wallet.conditions import AssertCoinAnnouncement, Condition, ConditionValidTimes from chia.wallet.derive_keys import find_owner_sk +from chia.wallet.puzzles.singleton_top_layer import SINGLETON_LAUNCHER from chia.wallet.transaction_record import TransactionRecord from chia.wallet.util.transaction_type import TransactionType from chia.wallet.util.tx_config import DEFAULT_TX_CONFIG, TXConfig diff --git a/chia/pools/puzzles/__init__.py b/chia/pools/puzzles/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/chia/pools/puzzles/pool_member_innerpuz.clsp b/chia/pools/puzzles/pool_member_innerpuz.clsp deleted file mode 100644 index be0f81dcdc91..000000000000 --- a/chia/pools/puzzles/pool_member_innerpuz.clsp +++ /dev/null @@ -1,70 +0,0 @@ -(mod (POOL_PUZZLE_HASH - P2_SINGLETON_PUZZLE_HASH - OWNER_PUBKEY - POOL_REWARD_PREFIX - WAITINGROOM_PUZHASH - Truths - p1 - pool_reward_height - ) - - - ; POOL_PUZZLE_HASH is commitment to the pool's puzzle hash - ; P2_SINGLETON_PUZZLE_HASH is the puzzle hash for your pay to singleton puzzle - ; OWNER_PUBKEY is the farmer pubkey which authorises a travel - ; POOL_REWARD_PREFIX is network-specific data (mainnet vs testnet) that helps determine if a coin is a pool reward - ; WAITINGROOM_PUZHASH is the puzzle_hash you'll go to when you initiate the leaving process - - ; Absorbing money if pool_reward_height is an atom - ; Escaping if pool_reward_height is () - - ; p1 is pool_reward_amount if absorbing money - ; p1 is extra_data key_value_list if escaping - - ; pool_reward_amount is the value of the coin reward - this is passed in so that this puzzle will still work after halvenings - ; pool_reward_height is the block height that the reward was generated at. This is used to calculate the coin ID. - ; key_value_list is signed extra data that the wallet may want to publicly announce for syncing purposes - - (include condition_codes.clib) - (include singleton_truths.clib) - - ; takes a lisp tree and returns the hash of it - (defun sha256tree (TREE) - (if (l TREE) - (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE))) - (sha256 1 TREE) - ) - ) - - (defun-inline calculate_pool_reward (pool_reward_height P2_SINGLETON_PUZZLE_HASH POOL_REWARD_PREFIX pool_reward_amount) - (sha256 (logior POOL_REWARD_PREFIX (logand (- (lsh (q . 1) (q . 128)) (q . 1)) pool_reward_height)) P2_SINGLETON_PUZZLE_HASH pool_reward_amount) - ) - - (defun absorb_pool_reward (POOL_PUZZLE_HASH my_inner_puzzle_hash my_amount pool_reward_amount pool_reward_id) - (list - (list CREATE_COIN my_inner_puzzle_hash my_amount) - (list CREATE_COIN POOL_PUZZLE_HASH pool_reward_amount) - (list CREATE_PUZZLE_ANNOUNCEMENT pool_reward_id) - (list ASSERT_COIN_ANNOUNCEMENT (sha256 pool_reward_id '$')) - ) - ) - - (defun-inline travel_to_waitingroom (OWNER_PUBKEY WAITINGROOM_PUZHASH my_amount extra_data) - (list (list AGG_SIG_ME OWNER_PUBKEY (sha256tree extra_data)) - (list CREATE_COIN WAITINGROOM_PUZHASH my_amount) - ) - ) - - ; main - - (if pool_reward_height - (absorb_pool_reward POOL_PUZZLE_HASH - (my_inner_puzzle_hash_truth Truths) - (my_amount_truth Truths) - p1 - (calculate_pool_reward pool_reward_height P2_SINGLETON_PUZZLE_HASH POOL_REWARD_PREFIX p1) - ) - (travel_to_waitingroom OWNER_PUBKEY WAITINGROOM_PUZHASH (my_amount_truth Truths) p1) - ) -) -) diff --git a/chia/pools/puzzles/pool_member_innerpuz.clsp.hex b/chia/pools/puzzles/pool_member_innerpuz.clsp.hex deleted file mode 100644 index c95c7e03836b..000000000000 --- a/chia/pools/puzzles/pool_member_innerpuz.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff8202ffffff01ff02ff16ffff04ff02ffff04ff05ffff04ff8204bfffff04ff8206bfffff04ff82017fffff04ffff0bffff19ff2fffff18ffff019100ffffffffffffffffffffffffffffffffff8202ff8080ff0bff82017f80ff8080808080808080ffff01ff04ffff04ff08ffff04ff17ffff04ffff02ff1effff04ff02ffff04ff82017fff80808080ff80808080ffff04ffff04ff1cffff04ff5fffff04ff8206bfff80808080ff80808080ff0180ffff04ffff01ffff32ff3d33ff3effff04ffff04ff1cffff04ff0bffff04ff17ff80808080ffff04ffff04ff1cffff04ff05ffff04ff2fff80808080ffff04ffff04ff0affff04ff5fff808080ffff04ffff04ff14ffff04ffff0bff5fffff012480ff808080ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/pools/puzzles/pool_waitingroom_innerpuz.clsp b/chia/pools/puzzles/pool_waitingroom_innerpuz.clsp deleted file mode 100644 index 9a8ba852c0e2..000000000000 --- a/chia/pools/puzzles/pool_waitingroom_innerpuz.clsp +++ /dev/null @@ -1,69 +0,0 @@ -(mod (POOL_PUZZLE_HASH - P2_SINGLETON_PUZZLE_HASH - OWNER_PUBKEY - POOL_REWARD_PREFIX - RELATIVE_LOCK_HEIGHT - Truths - spend_type - p1 - p2 - ) - - ; POOL_PUZZLE_HASH is commitment to the pool's puzzle hash - ; P2_SINGLETON_PUZZLE_HASH is the puzzlehash for your pay_to_singleton puzzle - ; OWNER_PUBKEY is the farmer pubkey which signs the exit puzzle_hash - ; POOL_REWARD_PREFIX is network-specific data (mainnet vs testnet) that helps determine if a coin is a pool reward - ; RELATIVE_LOCK_HEIGHT is how long it takes to leave - - ; spend_type is: 0 for absorbing money, 1 to escape - ; if spend_type is 0 - ; p1 is pool_reward_amount - the value of the coin reward - this is passed in so that this puzzle will still work after halvenings - ; p2 is pool_reward_height - the block height that the reward was generated at. This is used to calculate the coin ID. - ; if spend_type is 1 - ; p1 is extra_data key_value_list - signed extra data that the wallet may want to publicly announce for syncing purposes - ; p2 is destination_puzhash - the location that the escape spend wants to create itself to - - (include condition_codes.clib) - (include singleton_truths.clib) - - ; takes a lisp tree and returns the hash of it - (defun sha256tree (TREE) - (if (l TREE) - (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE))) - (sha256 1 TREE) - ) - ) - - (defun-inline calculate_pool_reward (pool_reward_height P2_SINGLETON_PUZZLE_HASH POOL_REWARD_PREFIX pool_reward_amount) - (sha256 (logior POOL_REWARD_PREFIX (logand (- (lsh (q . 1) (q . 128)) (q . 1)) pool_reward_height)) P2_SINGLETON_PUZZLE_HASH pool_reward_amount) - ) - - (defun absorb_pool_reward (POOL_PUZZLE_HASH my_inner_puzzle_hash my_amount pool_reward_amount pool_reward_id) - (list - (list CREATE_COIN my_inner_puzzle_hash my_amount) - (list CREATE_COIN POOL_PUZZLE_HASH pool_reward_amount) - (list CREATE_PUZZLE_ANNOUNCEMENT pool_reward_id) - (list ASSERT_COIN_ANNOUNCEMENT (sha256 pool_reward_id '$')) - ) - ) - - (defun-inline travel_spend (RELATIVE_LOCK_HEIGHT new_puzzle_hash my_amount extra_data) - (list (list ASSERT_HEIGHT_RELATIVE RELATIVE_LOCK_HEIGHT) - (list CREATE_COIN new_puzzle_hash my_amount) - (list AGG_SIG_ME OWNER_PUBKEY (sha256tree (list new_puzzle_hash extra_data))) - ) - ) - - ; main - - (if spend_type - (travel_spend RELATIVE_LOCK_HEIGHT p2 (my_amount_truth Truths) p1) - (absorb_pool_reward POOL_PUZZLE_HASH - (my_inner_puzzle_hash_truth Truths) - (my_amount_truth Truths) - p1 - (calculate_pool_reward p2 P2_SINGLETON_PUZZLE_HASH POOL_REWARD_PREFIX p1) - ) - ) - -) diff --git a/chia/pools/puzzles/pool_waitingroom_innerpuz.clsp.hex b/chia/pools/puzzles/pool_waitingroom_innerpuz.clsp.hex deleted file mode 100644 index e1504d7fa053..000000000000 --- a/chia/pools/puzzles/pool_waitingroom_innerpuz.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff82017fffff01ff04ffff04ff1cffff04ff5fff808080ffff04ffff04ff12ffff04ff8205ffffff04ff8206bfff80808080ffff04ffff04ff08ffff04ff17ffff04ffff02ff1effff04ff02ffff04ffff04ff8205ffffff04ff8202ffff808080ff80808080ff80808080ff80808080ffff01ff02ff16ffff04ff02ffff04ff05ffff04ff8204bfffff04ff8206bfffff04ff8202ffffff04ffff0bffff19ff2fffff18ffff019100ffffffffffffffffffffffffffffffffff8205ff8080ff0bff8202ff80ff808080808080808080ff0180ffff04ffff01ffff32ff3d52ffff333effff04ffff04ff12ffff04ff0bffff04ff17ff80808080ffff04ffff04ff12ffff04ff05ffff04ff2fff80808080ffff04ffff04ff1affff04ff5fff808080ffff04ffff04ff14ffff04ffff0bff5fffff012480ff808080ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/rpc/wallet_rpc_api.py b/chia/rpc/wallet_rpc_api.py index bd609aa038e1..97b6c69ab84d 100644 --- a/chia/rpc/wallet_rpc_api.py +++ b/chia/rpc/wallet_rpc_api.py @@ -131,9 +131,9 @@ match_did_puzzle, metadata_to_program, ) -from chia.wallet.nft_wallet import nft_puzzles +from chia.wallet.nft_wallet import nft_puzzle_utils from chia.wallet.nft_wallet.nft_info import NFTCoinInfo, NFTInfo -from chia.wallet.nft_wallet.nft_puzzles import get_metadata_and_phs +from chia.wallet.nft_wallet.nft_puzzle_utils import get_metadata_and_phs from chia.wallet.nft_wallet.nft_wallet import NFTWallet from chia.wallet.nft_wallet.uncurry_nft import UncurriedNFT from chia.wallet.notification_store import Notification @@ -3610,7 +3610,7 @@ async def nft_get_nfts(self, request: dict[str, Any]) -> EndpointResult: else: nfts = await self.service.wallet_state_manager.nft_store.get_nft_list(start_index=start_index, count=count) for nft in nfts: - nft_info = await nft_puzzles.get_nft_info_from_puzzle(nft, self.service.wallet_state_manager.config) + nft_info = await nft_puzzle_utils.get_nft_info_from_puzzle(nft, self.service.wallet_state_manager.config) nft_info_list.append(nft_info) return {"wallet_id": wallet_id, "success": True, "nft_list": nft_info_list} @@ -3628,7 +3628,7 @@ async def nft_set_nft_did( did_id = decode_puzzle_hash(did_id) nft_coin_info = await nft_wallet.get_nft_coin_by_id(bytes32.from_hexstr(request["nft_coin_id"])) if not ( - await nft_puzzles.get_nft_info_from_puzzle(nft_coin_info, self.service.wallet_state_manager.config) + await nft_puzzle_utils.get_nft_info_from_puzzle(nft_coin_info, self.service.wallet_state_manager.config) ).supports_did: return {"success": False, "error": "The NFT doesn't support setting a DID."} @@ -3689,7 +3689,7 @@ async def nft_set_did_bulk( nft_coin_info = await nft_wallet.get_nft_coin_by_id(nft_coin_id) assert nft_coin_info is not None if not ( - await nft_puzzles.get_nft_info_from_puzzle(nft_coin_info, self.service.wallet_state_manager.config) + await nft_puzzle_utils.get_nft_info_from_puzzle(nft_coin_info, self.service.wallet_state_manager.config) ).supports_did: log.warning(f"Skipping NFT {nft_coin_info.nft_id.hex()}, doesn't support setting a DID.") continue @@ -3926,13 +3926,13 @@ async def nft_get_info(self, request: dict[str, Any]) -> EndpointResult: # There is no way to rebuild the full puzzle in a different wallet. # But it shouldn't have impact on generating the NFTInfo, since inner_puzzle is not used there. if uncurried_nft.supports_did: - inner_puzzle = nft_puzzles.recurry_nft_puzzle( + inner_puzzle = nft_puzzle_utils.recurry_nft_puzzle( uncurried_nft, coin_spend.solution.to_program(), uncurried_nft.p2_puzzle ) else: inner_puzzle = uncurried_nft.p2_puzzle - full_puzzle = nft_puzzles.create_full_puzzle( + full_puzzle = nft_puzzle_utils.create_full_puzzle( uncurried_nft.singleton_launcher_id, metadata, bytes32(uncurried_nft.metadata_updater_hash.as_atom()), @@ -3950,7 +3950,7 @@ async def nft_get_info(self, request: dict[str, Any]) -> EndpointResult: } minter_did = await self.service.wallet_state_manager.get_minter_did(launcher_coin[0].coin, peer) - nft_info: NFTInfo = await nft_puzzles.get_nft_info_from_puzzle( + nft_info: NFTInfo = await nft_puzzle_utils.get_nft_info_from_puzzle( NFTCoinInfo( uncurried_nft.singleton_launcher_id, coin_state.coin, @@ -4128,7 +4128,7 @@ async def nft_mint_bulk( ) nft_id_list = [] for cs in sb.coin_spends: - if cs.coin.puzzle_hash == nft_puzzles.LAUNCHER_PUZZLE_HASH: + if cs.coin.puzzle_hash == SINGLETON_LAUNCHER_PUZZLE_HASH: nft_id_list.append(encode_puzzle_hash(cs.coin.name(), AddressType.NFT.hrp(self.service.config))) return { diff --git a/chia/simulator/block_tools.py b/chia/simulator/block_tools.py index a714ab361359..a841c0970489 100644 --- a/chia/simulator/block_tools.py +++ b/chia/simulator/block_tools.py @@ -17,6 +17,7 @@ from typing import Any, Callable, Optional import anyio +from chia_puzzles_py.programs import CHIALISP_DESERIALISATION, ROM_BOOTSTRAP_GENERATOR from chia_rs import MEMPOOL_MODE, AugSchemeMPL, G1Element, G2Element, PrivateKey, solution_generator from chia.consensus.block_creation import create_unfinished_block, unfinished_block_to_full_block @@ -113,15 +114,10 @@ master_sk_to_pool_sk, master_sk_to_wallet_sk, ) -from chia.wallet.puzzles.load_clvm import load_serialized_clvm_maybe_recompile -GENERATOR_MOD: SerializedProgram = load_serialized_clvm_maybe_recompile( - "rom_bootstrap_generator.clsp", package_or_requirement="chia.consensus.puzzles" -) +DESERIALIZE_MOD = Program.from_bytes(CHIALISP_DESERIALISATION) -DESERIALIZE_MOD = load_serialized_clvm_maybe_recompile( - "chialisp_deserialisation.clsp", package_or_requirement="chia.consensus.puzzles" -) +GENERATOR_MOD: SerializedProgram = SerializedProgram.from_bytes(ROM_BOOTSTRAP_GENERATOR) test_constants = DEFAULT_CONSTANTS.replace( MIN_PLOT_SIZE=uint8(18), diff --git a/chia/wallet/cat_wallet/cat_utils.py b/chia/wallet/cat_wallet/cat_utils.py index 0a634426d2dd..b582f96ae6d3 100644 --- a/chia/wallet/cat_wallet/cat_utils.py +++ b/chia/wallet/cat_wallet/cat_utils.py @@ -4,6 +4,7 @@ from collections.abc import Iterator from typing import Optional, Union +from chia_puzzles_py.programs import CAT_PUZZLE, CAT_PUZZLE_HASH from chia_rs import G2Element from chia.types.blockchain_format.coin import Coin, coin_as_list @@ -13,15 +14,16 @@ from chia.types.condition_opcodes import ConditionOpcode from chia.util.condition_tools import conditions_dict_for_solution from chia.wallet.lineage_proof import LineageProof -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.uncurried_puzzle import UncurriedPuzzle +from chia.wallet.util.curry_and_treehash import calculate_hash_of_quoted_mod_hash from chia.wallet.wallet_spend_bundle import WalletSpendBundle NULL_SIGNATURE = G2Element() ANYONE_CAN_SPEND_PUZZLE = Program.to(1) # simply return the conditions -CAT_MOD = load_clvm_maybe_recompile("cat_v2.clsp", package_or_requirement="chia.wallet.cat_wallet.puzzles") -CAT_MOD_HASH = CAT_MOD.get_tree_hash() +CAT_MOD = Program.from_bytes(CAT_PUZZLE) +CAT_MOD_HASH = bytes32(CAT_PUZZLE_HASH) +QUOTED_CAT_MOD_HASH = calculate_hash_of_quoted_mod_hash(CAT_MOD_HASH) CAT_MOD_HASH_HASH: bytes32 = Program.to(CAT_MOD_HASH).get_tree_hash() diff --git a/chia/wallet/cat_wallet/cat_wallet.py b/chia/wallet/cat_wallet/cat_wallet.py index ef16abf3a741..be70d1cca3c0 100644 --- a/chia/wallet/cat_wallet/cat_wallet.py +++ b/chia/wallet/cat_wallet/cat_wallet.py @@ -24,6 +24,8 @@ from chia.wallet.cat_wallet.cat_info import CATCoinData, CATInfo, LegacyCATInfo from chia.wallet.cat_wallet.cat_utils import ( CAT_MOD, + CAT_MOD_HASH_HASH, + QUOTED_CAT_MOD_HASH, SpendableCAT, construct_cat_puzzle, match_cat_puzzle, @@ -48,7 +50,7 @@ from chia.wallet.transaction_record import TransactionRecord from chia.wallet.uncurried_puzzle import uncurry_puzzle from chia.wallet.util.compute_memos import compute_memos -from chia.wallet.util.curry_and_treehash import calculate_hash_of_quoted_mod_hash, curry_and_treehash +from chia.wallet.util.curry_and_treehash import curry_and_treehash from chia.wallet.util.transaction_type import TransactionType from chia.wallet.util.wallet_sync_utils import fetch_coin_spend_for_coin_state from chia.wallet.util.wallet_types import WalletType @@ -62,12 +64,6 @@ if TYPE_CHECKING: from chia.wallet.wallet_state_manager import WalletStateManager -# This should probably not live in this file but it's for experimental right now - -CAT_MOD_HASH = CAT_MOD.get_tree_hash() -CAT_MOD_HASH_HASH = Program.to(CAT_MOD_HASH).get_tree_hash() -QUOTED_MOD_HASH = calculate_hash_of_quoted_mod_hash(CAT_MOD_HASH) - def not_ephemeral_additions(sp: WalletSpendBundle) -> list[Coin]: removals: set[Coin] = set() @@ -433,7 +429,9 @@ def puzzle_for_pk(self, pubkey: G1Element) -> Program: def puzzle_hash_for_pk(self, pubkey: G1Element) -> bytes32: inner_puzzle_hash = self.standard_wallet.puzzle_hash_for_pk(pubkey) limitations_program_hash_hash = Program.to(self.cat_info.limitations_program_hash).get_tree_hash() - return curry_and_treehash(QUOTED_MOD_HASH, CAT_MOD_HASH_HASH, limitations_program_hash_hash, inner_puzzle_hash) + return curry_and_treehash( + QUOTED_CAT_MOD_HASH, CAT_MOD_HASH_HASH, limitations_program_hash_hash, inner_puzzle_hash + ) async def get_cat_puzzle_hash(self, new: bool) -> bytes32: if new: diff --git a/chia/wallet/cat_wallet/dao_cat_wallet.py b/chia/wallet/cat_wallet/dao_cat_wallet.py index d6d33cac2360..418505e566d7 100644 --- a/chia/wallet/cat_wallet/dao_cat_wallet.py +++ b/chia/wallet/cat_wallet/dao_cat_wallet.py @@ -32,7 +32,6 @@ from chia.wallet.lineage_proof import LineageProof from chia.wallet.payment import Payment from chia.wallet.transaction_record import TransactionRecord -from chia.wallet.util.curry_and_treehash import calculate_hash_of_quoted_mod_hash from chia.wallet.util.transaction_type import TransactionType from chia.wallet.util.tx_config import TXConfig from chia.wallet.util.wallet_sync_utils import fetch_coin_spend @@ -46,10 +45,6 @@ if TYPE_CHECKING: from chia.wallet.wallet_state_manager import WalletStateManager -CAT_MOD_HASH = CAT_MOD.get_tree_hash() -CAT_MOD_HASH_HASH = Program.to(CAT_MOD_HASH).get_tree_hash() -QUOTED_MOD_HASH = calculate_hash_of_quoted_mod_hash(CAT_MOD_HASH) - class DAOCATWallet: if TYPE_CHECKING: diff --git a/chia/wallet/cat_wallet/puzzles/__init__.py b/chia/wallet/cat_wallet/puzzles/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/chia/wallet/cat_wallet/puzzles/cat_truths.clib b/chia/wallet/cat_wallet/puzzles/cat_truths.clib deleted file mode 100644 index 563ec65f3a56..000000000000 --- a/chia/wallet/cat_wallet/puzzles/cat_truths.clib +++ /dev/null @@ -1,31 +0,0 @@ -( - (defun-inline cat_truth_data_to_truth_struct (innerpuzhash cat_struct my_id this_coin_info) - (c - (c - innerpuzhash - cat_struct - ) - (c - my_id - this_coin_info - ) - ) - ) - - ; CAT Truths is: ((Inner puzzle hash . (MOD hash . (MOD hash hash . TAIL hash))) . (my_id . (my_parent_info my_puzhash my_amount))) - - (defun-inline my_inner_puzzle_hash_cat_truth (Truths) (f (f Truths))) - (defun-inline cat_struct_truth (Truths) (r (f Truths))) - (defun-inline my_id_cat_truth (Truths) (f (r Truths))) - (defun-inline my_coin_info_truth (Truths) (r (r Truths))) - (defun-inline my_amount_cat_truth (Truths) (f (r (r (my_coin_info_truth Truths))))) - (defun-inline my_full_puzzle_hash_cat_truth (Truths) (f (r (my_coin_info_truth Truths)))) - (defun-inline my_parent_cat_truth (Truths) (f (my_coin_info_truth Truths))) - - - ; CAT mod_struct is: (MOD_HASH MOD_HASH_hash TAIL_PROGRAM TAIL_PROGRAM_hash) - - (defun-inline cat_mod_hash_truth (Truths) (f (cat_struct_truth Truths))) - (defun-inline cat_mod_hash_hash_truth (Truths) (f (r (cat_struct_truth Truths)))) - (defun-inline cat_tail_program_hash_truth (Truths) (f (r (r (cat_struct_truth Truths))))) -) diff --git a/chia/wallet/cat_wallet/puzzles/cat_v2.clsp b/chia/wallet/cat_wallet/puzzles/cat_v2.clsp deleted file mode 100644 index aeebd641205c..000000000000 --- a/chia/wallet/cat_wallet/puzzles/cat_v2.clsp +++ /dev/null @@ -1,397 +0,0 @@ -; Coins locked with this puzzle are spendable cats. -; -; Choose a list of n inputs (n>=1), I_1, ... I_n with amounts A_1, ... A_n. -; -; We put them in a ring, so "previous" and "next" have intuitive k-1 and k+1 semantics, -; wrapping so {n} and 0 are the same, ie. all indices are mod n. -; -; Each coin creates 0 or more coins with total output value O_k. -; Let D_k = the "debt" O_k - A_k contribution of coin I_k, ie. how much debt this input accumulates. -; Some coins may spend more than they contribute and some may spend less, ie. D_k need -; not be zero. That's okay. It's enough for the total of all D_k in the ring to be 0. -; -; A coin can calculate its own D_k since it can verify A_k (it's hashed into the coin id) -; and it can sum up `CREATE_COIN` conditions for O_k. -; -; Defines a "subtotal of debts" S_k for each coin as follows: -; -; S_1 = 0 -; S_k = S_{k-1} + D_{k-1} -; -; Here's the main trick that shows the ring sums to 0. -; You can prove by induction that S_{k+1} = D_1 + D_2 + ... + D_k. -; But it's a ring, so S_{n+1} is also S_1, which is 0. So D_1 + D_2 + ... + D_k = 0. -; So the total debts must be 0, ie. no coins are created or destroyed. -; -; Each coin's solution includes I_{k-1}, I_k, and I_{k+1} along with proofs that I_{k}, and I_{k+1} are CATs of the same type. -; Each coin's solution includes S_{k-1}. It calculates D_k = O_k - A_k, and then S_k = S_{k-1} + D_{k-1} -; -; Announcements are used to ensure that each S_k follows the pattern is valid. -; Announcements automatically commit to their own coin id. -; Coin I_k creates an announcement that further commits to I_{k-1} and S_{k-1}. -; -; Coin I_k gets a proof that I_{k+1} is a cat, so it knows it must also create an announcement -; when spent. It checks that I_{k+1} creates an announcement committing to I_k and S_k. -; -; So S_{k+1} is correct iff S_k is correct. -; -; Coins also receive proofs that their neighbours are CATs, ensuring the announcements aren't forgeries. -; Inner puzzles and the CAT layer prepend `CREATE_COIN_ANNOUNCEMENT` with different prefixes to avoid forgeries. -; Ring announcements use 0xcb, and inner puzzles are given 0xca -; -; In summary, I_k generates a coin_announcement Y_k ("Y" for "yell") as follows: -; -; Y_k: hash of I_k (automatically), I_{k-1}, S_k -; -; Each coin creates an assert_coin_announcement to ensure that the next coin's announcement is as expected: -; Y_{k+1} : hash of I_{k+1}, I_k, S_{k+1} -; -; TLDR: -; I_k : coins -; A_k : amount coin k contributes -; O_k : amount coin k spend -; D_k : difference/delta that coin k incurs (A - O) -; S_k : subtotal of debts D_1 + D_2 ... + D_k -; Y_k : announcements created by coin k committing to I_{k-1}, I_k, S_k -; -; All conditions go through a "transformer" that looks for CREATE_COIN conditions -; generated by the inner solution, and wraps the puzzle hash ensuring the output is a cat. -; -; Three output conditions are prepended to the list of conditions for each I_k: -; (ASSERT_MY_ID I_k) to ensure that the passed in value for I_k is correct -; (CREATE_COIN_ANNOUNCEMENT I_{k-1} S_k) to create this coin's announcement -; (ASSERT_COIN_ANNOUNCEMENT hashed_announcement(Y_{k+1})) to ensure the next coin really is next and -; the relative values of S_k and S_{k+1} are correct -; -; This is all we need to do to ensure cats exactly balance in the inputs and outputs. -; -; Proof: -; Consider n, k, I_k values, O_k values, S_k and A_k as above. -; For the (CREATE_COIN_ANNOUNCEMENT Y_{k+1}) (created by the next coin) -; and (ASSERT_COIN_ANNOUNCEMENT hashed(Y_{k+1})) to match, -; we see that I_k can ensure that is has the correct value for S_{k+1}. -; -; By induction, we see that S_{m+1} = sum(i, 1, m) [O_i - A_i] = sum(i, 1, m) O_i - sum(i, 1, m) A_i -; So S_{n+1} = sum(i, 1, n) O_i - sum(i, 1, n) A_i. But S_{n+1} is actually S_1 = 0, -; so thus sum(i, 1, n) O_i = sum (i, 1, n) A_i, ie. output total equals input total. - -;; GLOSSARY: -;; MOD_HASH: this code's sha256 tree hash -;; TAIL_PROGRAM_HASH: the program that determines if a coin can mint new cats, burn cats, and check if its lineage is valid if its parent is not a CAT -;; INNER_PUZZLE: an independent puzzle protecting the coins. Solutions to this puzzle are expected to generate `AGG_SIG` conditions and possibly `CREATE_COIN` conditions. -;; ---- items above are curried into the puzzle hash ---- -;; inner_puzzle_solution: the solution to the inner puzzle -;; prev_coin_id: the id for the previous coin -;; tail_program_reveal: reveal of TAIL_PROGRAM_HASH required to run the program if desired -;; tail_solution: optional solution passed into tail_program -;; lineage_proof: optional proof that our coin's parent is a CAT -;; this_coin_info: (parent_id puzzle_hash amount) -;; next_coin_proof: (parent_id inner_puzzle_hash amount) -;; prev_subtotal: the subtotal between prev-coin and this-coin -;; extra_delta: an amount that is added to our delta and checked by the TAIL program -;; - -(mod ( - MOD_HASH ;; curried into puzzle - TAIL_PROGRAM_HASH ;; curried into puzzle - INNER_PUZZLE ;; curried into puzzle - inner_puzzle_solution ;; if invalid, INNER_PUZZLE will fail - lineage_proof ;; This is the parent's coin info, used to check if the parent was a CAT. Optional if using tail_program. - prev_coin_id ;; used in this coin's announcement, prev_coin ASSERT_COIN_ANNOUNCEMENT will fail if wrong - this_coin_info ;; verified with ASSERT_MY_COIN_ID - next_coin_proof ;; used to generate ASSERT_COIN_ANNOUNCEMENT - prev_subtotal ;; included in announcement, prev_coin ASSERT_COIN_ANNOUNCEMENT will fail if wrong - extra_delta ;; this is the "legal discrepancy" between your real delta and what you're announcing your delta is - ) - - ;;;;; start library code - - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include cat_truths.clib) - (include utility_macros.clib) - - (defconstant RING_MORPH_BYTE 0xcb) - - - ; take two lists and merge them into one - (defun merge_list (list_a list_b) - (if list_a - (c (f list_a) (merge_list (r list_a) list_b)) - list_b - ) - ) - - ; cat_mod_struct = (MOD_HASH MOD_HASH_hash GENESIS_COIN_CHECKER GENESIS_COIN_CHECKER_hash) - - (defun-inline mod_hash_from_cat_mod_struct (cat_mod_struct) (f cat_mod_struct)) - (defun-inline mod_hash_hash_from_cat_mod_struct (cat_mod_struct) (f (r cat_mod_struct))) - (defun-inline tail_program_hash_from_cat_mod_struct (cat_mod_struct) (f (r (r cat_mod_struct)))) - - ;;;;; end library code - - ;; return the puzzle hash for a cat with the given `GENESIS_COIN_CHECKER_hash` & `INNER_PUZZLE` - (defun-inline cat_puzzle_hash (cat_mod_struct inner_puzzle_hash) - (puzzle-hash-of-curried-function (mod_hash_from_cat_mod_struct cat_mod_struct) - inner_puzzle_hash - (sha256 ONE (tail_program_hash_from_cat_mod_struct cat_mod_struct)) - (mod_hash_hash_from_cat_mod_struct cat_mod_struct) - ) - ) - - ;; assert `CREATE_COIN_ANNOUNCEMENT` doesn't contain the RING_MORPH_BYTE bytes so it cannot be used to cheat the coin ring - - (defun-inline morph_condition (condition cat_mod_struct) - (if (= (f condition) CREATE_COIN) - (c CREATE_COIN - (c (cat_puzzle_hash cat_mod_struct (f (r condition))) - (r (r condition))) - ) - (if (= (f condition) CREATE_COIN_ANNOUNCEMENT) - (assert (not (and - (= 33 (strlen (f (r condition)))) - (= (substr (f (r condition)) 0 ONE) RING_MORPH_BYTE) ; lazy eval - )) - ; then - condition - ) - condition - ) - ) - ) - - ;; given a coin's parent, inner_puzzle and amount, and the cat_mod_struct, calculate the id of the coin - (defun-inline coin_id_for_proof (coin cat_mod_struct) - (calculate_coin_id (f coin) (cat_puzzle_hash cat_mod_struct (f (r coin))) (f (r (r coin)))) - ) - - ;; utility to fetch coin amount from coin - (defun-inline input_amount_for_coin (coin) - (f (r (r coin))) - ) - - ;; calculate the hash of an announcement - ;; we add 0xcb so ring announcements exist in a different namespace to announcements from inner_puzzles - (defun-inline calculate_annoucement_id (this_coin_id this_subtotal next_coin_id cat_mod_struct) - (sha256 next_coin_id RING_MORPH_BYTE (sha256tree (list this_coin_id this_subtotal))) - ) - - ;; create the `ASSERT_COIN_ANNOUNCEMENT` condition that ensures the next coin's announcement is correct - (defun-inline create_assert_next_announcement_condition (this_coin_id this_subtotal next_coin_id cat_mod_struct) - (list ASSERT_COIN_ANNOUNCEMENT - (calculate_annoucement_id this_coin_id - this_subtotal - next_coin_id - cat_mod_struct - ) - ) - ) - - ;; here we commit to I_{k-1} and S_k - ;; we add 0xcb so ring announcements exist in a different namespace to announcements from inner_puzzles - (defun-inline create_announcement_condition (prev_coin_id prev_subtotal) - (list CREATE_COIN_ANNOUNCEMENT - (concat RING_MORPH_BYTE (sha256tree (list prev_coin_id prev_subtotal))) - ) - ) - - ;;;;;;;;;;;;;;;;;;;;;;;;;;; - - ;; this function takes a condition and returns an integer indicating - ;; the value of all output coins created with CREATE_COIN. If it's not - ;; a CREATE_COIN condition, it returns 0. - - (defun-inline output_value_for_condition (condition) - (if (= (f condition) CREATE_COIN) - (f (r (r condition))) - 0 - ) - ) - - ;; add two conditions to the list of morphed conditions: - ;; CREATE_COIN_ANNOUNCEMENT for my announcement - ;; ASSERT_COIN_ANNOUNCEMENT for the next coin's announcement - (defun-inline generate_final_output_conditions - ( - prev_subtotal - this_subtotal - morphed_conditions - prev_coin_id - this_coin_id - next_coin_id - cat_mod_struct - ) - (c (create_announcement_condition prev_coin_id prev_subtotal) - (c (create_assert_next_announcement_condition this_coin_id this_subtotal next_coin_id cat_mod_struct) - morphed_conditions) - ) - ) - - - ;; This next section of code loops through all of the conditions to do three things: - ;; 1) Look for a "magic" value of -113 and, if one exists, filter it, and take note of the tail reveal and solution - ;; 2) Morph any CREATE_COIN or CREATE_COIN_ANNOUNCEMENT conditions - ;; 3) Sum the total output amount of all of the CREATE_COINs that are output by the inner puzzle - ;; - ;; After everything return a struct in the format (morphed_conditions . (output_sum . tail_reveal_and_solution)) - ;; If multiple magic conditions are specified, the later one will take precedence - - (defun-inline condition_tail_reveal (condition) (f (r (r (r condition))))) - (defun-inline condition_tail_solution (condition) (f (r (r (r (r condition)))))) - - (defun cons_onto_first_and_add_to_second (morphed_condition output_value struct) - (c (c morphed_condition (f struct)) (c (+ output_value (f (r struct))) (r (r struct)))) - ) - - (defun find_and_strip_tail_info (inner_conditions cat_mod_struct tail_reveal_and_solution) - (if inner_conditions - (if (= (output_value_for_condition (f inner_conditions)) -113) ; Checks this is a CREATE_COIN of value -113 - (find_and_strip_tail_info - (r inner_conditions) - cat_mod_struct - (c (condition_tail_reveal (f inner_conditions)) (condition_tail_solution (f inner_conditions))) - ) - (cons_onto_first_and_add_to_second - (morph_condition (f inner_conditions) cat_mod_struct) - (output_value_for_condition (f inner_conditions)) - (find_and_strip_tail_info - (r inner_conditions) - cat_mod_struct - tail_reveal_and_solution - ) - ) - ) - (c () (c 0 tail_reveal_and_solution)) - ) - ) - - ;;;;;;;;;;;;;;;;;;;;;;;;;;; lineage checking - - ;; return true iff parent of `this_coin_info` is provably a cat - ;; A 'lineage proof' consists of (parent_parent_id parent_INNER_puzzle_hash parent_amount) - ;; We use this information to construct a coin who's puzzle has been wrapped in this MOD and verify that, - ;; once wrapped, it matches our parent coin's ID. - (defun-inline is_parent_cat ( - cat_mod_struct - parent_id - lineage_proof - ) - (= parent_id - (calculate_coin_id (f lineage_proof) - (cat_puzzle_hash cat_mod_struct (f (r lineage_proof))) - (f (r (r lineage_proof))) - ) - ) - ) - - (defun check_lineage_or_run_tail_program - ( - this_coin_info - tail_reveal_and_solution - parent_is_cat ; flag which says whether or not the parent CAT check ran and passed - lineage_proof - Truths - extra_delta - inner_conditions - ) - (if tail_reveal_and_solution - (assert (= (sha256tree (f tail_reveal_and_solution)) (cat_tail_program_hash_truth Truths)) - (merge_list - (a (f tail_reveal_and_solution) - (list - Truths - parent_is_cat - lineage_proof ; Lineage proof is only guaranteed to be true if parent_is_cat - extra_delta - inner_conditions - (r tail_reveal_and_solution) - ) - ) - inner_conditions - ) - ) - (assert parent_is_cat (not extra_delta) - inner_conditions - ) - ) - ) - - ;;;;;;;;;;;;;;;;;;;;;;;;;;; - - (defun stager_two ( - Truths - (inner_conditions . (output_sum . tail_reveal_and_solution)) - lineage_proof - prev_coin_id - this_coin_info - next_coin_id - prev_subtotal - extra_delta - ) - (check_lineage_or_run_tail_program - this_coin_info - tail_reveal_and_solution - (if lineage_proof (is_parent_cat (cat_struct_truth Truths) (my_parent_cat_truth Truths) lineage_proof) ()) - lineage_proof - Truths - extra_delta - (generate_final_output_conditions - prev_subtotal - ; the expression on the next line calculates `this_subtotal` by adding the delta to `prev_subtotal` - (+ prev_subtotal (- (input_amount_for_coin this_coin_info) output_sum) extra_delta) - inner_conditions - prev_coin_id - (my_id_cat_truth Truths) - next_coin_id - (cat_struct_truth Truths) - ) - ) - ) - - ; CAT TRUTHS struct is: ; CAT Truths is: ((Inner puzzle hash . (MOD hash . (MOD hash hash . TAIL hash))) . (my_id . (my_parent_info my_puzhash my_amount))) - ; create truths - this_coin_info verified true because we calculated my ID from it! - ; lineage proof is verified later by cat parent check or tail_program - - (defun stager ( - cat_mod_struct - inner_conditions - lineage_proof - inner_puzzle_hash - my_id - prev_coin_id - this_coin_info - next_coin_proof - prev_subtotal - extra_delta - ) - (c (list ASSERT_MY_COIN_ID my_id) (stager_two - (cat_truth_data_to_truth_struct - inner_puzzle_hash - cat_mod_struct - my_id - this_coin_info - ) - (find_and_strip_tail_info inner_conditions cat_mod_struct ()) - lineage_proof - prev_coin_id - this_coin_info - (coin_id_for_proof next_coin_proof cat_mod_struct) - prev_subtotal - extra_delta - )) - ) - - (stager - ;; calculate cat_mod_struct, inner_puzzle_hash, coin_id - (list MOD_HASH (sha256 ONE MOD_HASH) TAIL_PROGRAM_HASH) - (a INNER_PUZZLE inner_puzzle_solution) - lineage_proof - (sha256tree INNER_PUZZLE) - (calculate_coin_id (f this_coin_info) (f (r this_coin_info)) (f (r (r this_coin_info)))) - prev_coin_id ; ID - this_coin_info ; (parent_id puzzle_hash amount) - next_coin_proof ; (parent_id innerpuzhash amount) - prev_subtotal - extra_delta - ) -) diff --git a/chia/wallet/cat_wallet/puzzles/cat_v2.clsp.hex b/chia/wallet/cat_wallet/puzzles/cat_v2.clsp.hex deleted file mode 100644 index 5cbde1ad697c..000000000000 --- a/chia/wallet/cat_wallet/puzzles/cat_v2.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ff5effff04ff02ffff04ffff04ff05ffff04ffff0bff34ff0580ffff04ff0bff80808080ffff04ffff02ff17ff2f80ffff04ff5fffff04ffff02ff2effff04ff02ffff04ff17ff80808080ffff04ffff02ff2affff04ff02ffff04ff82027fffff04ff82057fffff04ff820b7fff808080808080ffff04ff81bfffff04ff82017fffff04ff8202ffffff04ff8205ffffff04ff820bffff80808080808080808080808080ffff04ffff01ffffffff3d46ff02ff333cffff0401ff01ff81cb02ffffff20ff02ffff03ff05ffff01ff02ff32ffff04ff02ffff04ff0dffff04ffff0bff7cffff0bff34ff2480ffff0bff7cffff0bff7cffff0bff34ff2c80ff0980ffff0bff7cff0bffff0bff34ff8080808080ff8080808080ffff010b80ff0180ffff02ffff03ffff22ffff09ffff0dff0580ff2280ffff09ffff0dff0b80ff2280ffff15ff17ffff0181ff8080ffff01ff0bff05ff0bff1780ffff01ff088080ff0180ffff02ffff03ff0bffff01ff02ffff03ffff09ffff02ff2effff04ff02ffff04ff13ff80808080ff820b9f80ffff01ff02ff56ffff04ff02ffff04ffff02ff13ffff04ff5fffff04ff17ffff04ff2fffff04ff81bfffff04ff82017fffff04ff1bff8080808080808080ffff04ff82017fff8080808080ffff01ff088080ff0180ffff01ff02ffff03ff17ffff01ff02ffff03ffff20ff81bf80ffff0182017fffff01ff088080ff0180ffff01ff088080ff018080ff0180ff04ffff04ff05ff2780ffff04ffff10ff0bff5780ff778080ffffff02ffff03ff05ffff01ff02ffff03ffff09ffff02ffff03ffff09ff11ff5880ffff0159ff8080ff0180ffff01818f80ffff01ff02ff26ffff04ff02ffff04ff0dffff04ff0bffff04ffff04ff81b9ff82017980ff808080808080ffff01ff02ff7affff04ff02ffff04ffff02ffff03ffff09ff11ff5880ffff01ff04ff58ffff04ffff02ff76ffff04ff02ffff04ff13ffff04ff29ffff04ffff0bff34ff5b80ffff04ff2bff80808080808080ff398080ffff01ff02ffff03ffff09ff11ff7880ffff01ff02ffff03ffff20ffff02ffff03ffff09ffff0121ffff0dff298080ffff01ff02ffff03ffff09ffff0cff29ff80ff3480ff5c80ffff01ff0101ff8080ff0180ff8080ff018080ffff0109ffff01ff088080ff0180ffff010980ff018080ff0180ffff04ffff02ffff03ffff09ff11ff5880ffff0159ff8080ff0180ffff04ffff02ff26ffff04ff02ffff04ff0dffff04ff0bffff04ff17ff808080808080ff80808080808080ff0180ffff01ff04ff80ffff04ff80ff17808080ff0180ffff02ffff03ff05ffff01ff04ff09ffff02ff56ffff04ff02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ff0bff7cffff0bff34ff2880ffff0bff7cffff0bff7cffff0bff34ff2c80ff0580ffff0bff7cffff02ff32ffff04ff02ffff04ff07ffff04ffff0bff34ff3480ff8080808080ffff0bff34ff8080808080ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff2effff04ff02ffff04ff09ff80808080ffff02ff2effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ffff04ffff04ff30ffff04ff5fff808080ffff02ff7effff04ff02ffff04ffff04ffff04ff2fff0580ffff04ff5fff82017f8080ffff04ffff02ff26ffff04ff02ffff04ff0bffff04ff05ffff01ff808080808080ffff04ff17ffff04ff81bfffff04ff82017fffff04ffff02ff2affff04ff02ffff04ff8204ffffff04ffff02ff76ffff04ff02ffff04ff09ffff04ff820affffff04ffff0bff34ff2d80ffff04ff15ff80808080808080ffff04ff8216ffff808080808080ffff04ff8205ffffff04ff820bffff808080808080808080808080ff02ff5affff04ff02ffff04ff5fffff04ff3bffff04ffff02ffff03ff17ffff01ff09ff2dffff02ff2affff04ff02ffff04ff27ffff04ffff02ff76ffff04ff02ffff04ff29ffff04ff57ffff04ffff0bff34ff81b980ffff04ff59ff80808080808080ffff04ff81b7ff80808080808080ff8080ff0180ffff04ff17ffff04ff05ffff04ff8202ffffff04ffff04ffff04ff78ffff04ffff0eff5cffff02ff2effff04ff02ffff04ffff04ff2fffff04ff82017fff808080ff8080808080ff808080ffff04ffff04ff20ffff04ffff0bff81bfff5cffff02ff2effff04ff02ffff04ffff04ff15ffff04ffff10ff82017fffff11ff8202dfff2b80ff8202ff80ff808080ff8080808080ff808080ff138080ff80808080808080808080ff018080 diff --git a/chia/wallet/cat_wallet/puzzles/delegated_tail.clsp b/chia/wallet/cat_wallet/puzzles/delegated_tail.clsp deleted file mode 100644 index 91acd4b44944..000000000000 --- a/chia/wallet/cat_wallet/puzzles/delegated_tail.clsp +++ /dev/null @@ -1,25 +0,0 @@ -; This is a "limitations_program" for use with cat.clsp. -(mod ( - PUBKEY - Truths - parent_is_cat - lineage_proof - delta - inner_conditions - ( - delegated_puzzle - delegated_solution - ) - ) - - (include condition_codes.clib) - - (defun sha256tree1 (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE))) - - (c (list AGG_SIG_UNSAFE PUBKEY (sha256tree1 delegated_puzzle)) - (a delegated_puzzle (c Truths (c parent_is_cat (c lineage_proof (c delta (c inner_conditions delegated_solution)))))) - ) -) diff --git a/chia/wallet/cat_wallet/puzzles/delegated_tail.clsp.hex b/chia/wallet/cat_wallet/puzzles/delegated_tail.clsp.hex deleted file mode 100644 index 84595c2a09dd..000000000000 --- a/chia/wallet/cat_wallet/puzzles/delegated_tail.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff82027fff80808080ff80808080ffff02ff82027fffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff81bfff82057f80808080808080ffff04ffff01ff31ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp b/chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp deleted file mode 100644 index 46b7c73d8cac..000000000000 --- a/chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp +++ /dev/null @@ -1,15 +0,0 @@ -; This is a "limitations_program" for use with cat.clsp. -(mod ( - PUBKEY - Truths - parent_is_cat - lineage_proof - delta - inner_conditions - _ - ) - - (include condition_codes.clib) - - (list (list AGG_SIG_ME PUBKEY delta)) ; Careful with a delta of zero, the bytecode is 80 not 00 -) diff --git a/chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp.hex b/chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp.hex deleted file mode 100644 index 1fee44a358e1..000000000000 --- a/chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff02ffff04ff05ffff04ff5fff80808080ff8080ffff04ffff0132ff018080 diff --git a/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp b/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp deleted file mode 100644 index ac2ae60b18a0..000000000000 --- a/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp +++ /dev/null @@ -1,26 +0,0 @@ -; This is a TAIL for use with cat.clvm. -; -; This checker allows new CATs to be created if they have a particular coin id as parent -; -; The genesis_id is curried in, making this lineage_check program unique and giving the CAT it's uniqueness -(mod ( - GENESIS_ID - Truths - parent_is_cat - lineage_proof - delta - inner_conditions - _ - ) - - (include cat_truths.clib) - - (if delta - (x) - (if (= (my_parent_cat_truth Truths) GENESIS_ID) - () - (x) - ) - ) - -) diff --git a/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp.hex b/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp.hex deleted file mode 100644 index fe7dc034ad0e..000000000000 --- a/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff03ff2fffff01ff0880ffff01ff02ffff03ffff09ff2dff0280ff80ffff01ff088080ff018080ff0180 diff --git a/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp b/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp deleted file mode 100644 index 77975679f9b5..000000000000 --- a/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp +++ /dev/null @@ -1,42 +0,0 @@ -; This is a TAIL for use with cat.clvm. -; -; This checker allows new CATs to be created if they have a particular coin id as parent -; -; The genesis_id is curried in, making this lineage_check program unique and giving the CAT it's uniqueness -(mod ( - GENESIS_ID - MINT_LAUNCHER_PUZZLE_HASH - Truths - parent_is_cat - lineage_proof - delta - inner_conditions - ( ; solution - parent_parent_id - parent_amount - ) - ) - - (include cat_truths.clib) - (include curry-and-treehash.clib) - - (if delta - (x) - (if (= (my_parent_cat_truth Truths) GENESIS_ID) - () - (if - (= - (my_parent_cat_truth Truths) - (sha256 - parent_parent_id - MINT_LAUNCHER_PUZZLE_HASH - parent_amount - ) - ) - () - (x) - ) - ) - ) - -) diff --git a/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp.hex b/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp.hex deleted file mode 100644 index 99dcc60450dd..000000000000 --- a/chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff03ff5fffff01ff0880ffff01ff02ffff03ffff09ff5bff0280ff80ffff01ff02ffff03ffff09ff5bffff0bff82027fff05ff82057f8080ff80ffff01ff088080ff018080ff018080ff0180 diff --git a/chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp b/chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp deleted file mode 100644 index 691d75695de5..000000000000 --- a/chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp +++ /dev/null @@ -1,24 +0,0 @@ -; This is a "limitations_program" for use with cat.clsp. -; -; This checker allows new CATs to be created if their parent has a particular puzzle hash -(mod ( - GENESIS_PUZZLE_HASH - Truths - parent_is_cat - lineage_proof - delta - inner_conditions - (parent_parent_id parent_amount) - ) - - (include cat_truths.clib) - - ; Returns nil since we don't need to add any conditions - (if delta - (x) - (if (= (sha256 parent_parent_id GENESIS_PUZZLE_HASH parent_amount) (my_parent_cat_truth Truths)) - () - (x) - ) - ) -) diff --git a/chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp.hex b/chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp.hex deleted file mode 100644 index 24fe11e856b3..000000000000 --- a/chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff03ff2fffff01ff0880ffff01ff02ffff03ffff09ffff0bff82013fff02ff8202bf80ff2d80ff80ffff01ff088080ff018080ff0180 diff --git a/chia/wallet/dao_wallet/dao_utils.py b/chia/wallet/dao_wallet/dao_utils.py index 64ee2cf9fd11..91103972f447 100644 --- a/chia/wallet/dao_wallet/dao_utils.py +++ b/chia/wallet/dao_wallet/dao_utils.py @@ -5,6 +5,75 @@ from itertools import chain from typing import Any, Optional, Union +from chia_puzzles_py.programs import ( + DAO_CAT_EVE as DAO_CAT_EVE_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_CAT_LAUNCHER as DAO_CAT_LAUNCHER_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_FINISHED_STATE as DAO_FINISHED_STATE_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_FINISHED_STATE_HASH as DAO_FINISHED_STATE_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_LOCKUP as DAO_LOCKUP_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_LOCKUP_HASH as DAO_LOCKUP_MOD_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_PROPOSAL as DAO_PROPOSAL_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_PROPOSAL_HASH as DAO_PROPOSAL_MOD_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_PROPOSAL_TIMER as DAO_PROPOSAL_TIMER_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_PROPOSAL_TIMER_HASH as DAO_PROPOSAL_TIMER_MOD_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_PROPOSAL_VALIDATOR as DAO_PROPOSAL_VALIDATOR_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_PROPOSAL_VALIDATOR_HASH as DAO_PROPOSAL_VALIDATOR_MOD_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_SPEND_P2_SINGLETON as SPEND_P2_SINGLETON_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_SPEND_P2_SINGLETON_HASH as SPEND_P2_SINGLETON_MOD_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_TREASURY as DAO_TREASURY_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_TREASURY_HASH as DAO_TREASURY_MOD_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_UPDATE_PROPOSAL as DAO_UPDATE_PROPOSAL_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + DAO_UPDATE_PROPOSAL_HASH as DAO_UPDATE_PROPOSAL_MOD_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + GENESIS_BY_COIN_ID_OR_SINGLETON as DAO_CAT_TAIL_BYTES, +) +from chia_puzzles_py.programs import ( + GENESIS_BY_COIN_ID_OR_SINGLETON_HASH as DAO_CAT_TAIL_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + P2_SINGLETON_AGGREGATOR as P2_SINGLETON_AGGREGATOR_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + P2_SINGLETON_VIA_DELEGATED_PUZZLE as P2_SINGLETON_MOD_BYTES, +) +from chia_puzzles_py.programs import ( + P2_SINGLETON_VIA_DELEGATED_PUZZLE_HASH as P2_SINGLETON_MOD_HASH_BYTES, +) from clvm.EvalError import EvalError from chia.types.blockchain_format.coin import Coin @@ -13,40 +82,54 @@ from chia.util.ints import uint64 from chia.wallet.cat_wallet.cat_utils import CAT_MOD, CAT_MOD_HASH, construct_cat_puzzle from chia.wallet.dao_wallet.dao_info import DAORules, ProposalType -from chia.wallet.puzzles.load_clvm import load_clvm from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import MOD +from chia.wallet.singleton import ( + SINGLETON_LAUNCHER_PUZZLE_HASH as SINGLETON_LAUNCHER_HASH, +) +from chia.wallet.singleton import ( + SINGLETON_TOP_LAYER_MOD as SINGLETON_MOD, +) +from chia.wallet.singleton import ( + SINGLETON_TOP_LAYER_MOD_HASH as SINGLETON_MOD_HASH, +) from chia.wallet.singleton import get_singleton_struct_for_id from chia.wallet.uncurried_puzzle import UncurriedPuzzle -SINGLETON_MOD: Program = load_clvm("singleton_top_layer_v1_1.clsp") -SINGLETON_MOD_HASH: bytes32 = SINGLETON_MOD.get_tree_hash() -SINGLETON_LAUNCHER: Program = load_clvm("singleton_launcher.clsp") -SINGLETON_LAUNCHER_HASH: bytes32 = SINGLETON_LAUNCHER.get_tree_hash() -DAO_LOCKUP_MOD: Program = load_clvm("dao_lockup.clsp") -DAO_LOCKUP_MOD_HASH: bytes32 = DAO_LOCKUP_MOD.get_tree_hash() -DAO_PROPOSAL_TIMER_MOD: Program = load_clvm("dao_proposal_timer.clsp") -DAO_PROPOSAL_TIMER_MOD_HASH: bytes32 = DAO_PROPOSAL_TIMER_MOD.get_tree_hash() -DAO_PROPOSAL_MOD: Program = load_clvm("dao_proposal.clsp") -DAO_PROPOSAL_MOD_HASH: bytes32 = DAO_PROPOSAL_MOD.get_tree_hash() -DAO_PROPOSAL_VALIDATOR_MOD: Program = load_clvm("dao_proposal_validator.clsp") -DAO_PROPOSAL_VALIDATOR_MOD_HASH: bytes32 = DAO_PROPOSAL_VALIDATOR_MOD.get_tree_hash() -DAO_TREASURY_MOD: Program = load_clvm("dao_treasury.clsp") -DAO_TREASURY_MOD_HASH: bytes32 = DAO_TREASURY_MOD.get_tree_hash() -SPEND_P2_SINGLETON_MOD: Program = load_clvm("dao_spend_p2_singleton_v2.clsp") -SPEND_P2_SINGLETON_MOD_HASH: bytes32 = SPEND_P2_SINGLETON_MOD.get_tree_hash() -DAO_FINISHED_STATE: Program = load_clvm("dao_finished_state.clsp") -DAO_FINISHED_STATE_HASH: bytes32 = DAO_FINISHED_STATE.get_tree_hash() -DAO_CAT_TAIL: Program = load_clvm( - "genesis_by_coin_id_or_singleton.clsp", package_or_requirement="chia.wallet.cat_wallet.puzzles" -) -DAO_CAT_TAIL_HASH: bytes32 = DAO_CAT_TAIL.get_tree_hash() -DAO_CAT_LAUNCHER: Program = load_clvm("dao_cat_launcher.clsp") -P2_SINGLETON_MOD: Program = load_clvm("p2_singleton_via_delegated_puzzle.clsp") -P2_SINGLETON_MOD_HASH: bytes32 = P2_SINGLETON_MOD.get_tree_hash() -DAO_UPDATE_PROPOSAL_MOD: Program = load_clvm("dao_update_proposal.clsp") -DAO_UPDATE_PROPOSAL_MOD_HASH: bytes32 = DAO_UPDATE_PROPOSAL_MOD.get_tree_hash() -DAO_CAT_EVE: Program = load_clvm("dao_cat_eve.clsp") -P2_SINGLETON_AGGREGATOR_MOD: Program = load_clvm("p2_singleton_aggregator.clsp") +DAO_LOCKUP_MOD = Program.from_bytes(DAO_LOCKUP_MOD_BYTES) +DAO_LOCKUP_MOD_HASH = bytes32(DAO_LOCKUP_MOD_HASH_BYTES) + +DAO_PROPOSAL_TIMER_MOD = Program.from_bytes(DAO_PROPOSAL_TIMER_MOD_BYTES) +DAO_PROPOSAL_TIMER_MOD_HASH = bytes32(DAO_PROPOSAL_TIMER_MOD_HASH_BYTES) + +DAO_PROPOSAL_MOD = Program.from_bytes(DAO_PROPOSAL_MOD_BYTES) +DAO_PROPOSAL_MOD_HASH = bytes32(DAO_PROPOSAL_MOD_HASH_BYTES) + +DAO_PROPOSAL_VALIDATOR_MOD = Program.from_bytes(DAO_PROPOSAL_VALIDATOR_MOD_BYTES) +DAO_PROPOSAL_VALIDATOR_MOD_HASH = bytes32(DAO_PROPOSAL_VALIDATOR_MOD_HASH_BYTES) + +DAO_TREASURY_MOD = Program.from_bytes(DAO_TREASURY_MOD_BYTES) +DAO_TREASURY_MOD_HASH = bytes32(DAO_TREASURY_MOD_HASH_BYTES) + +SPEND_P2_SINGLETON_MOD = Program.from_bytes(SPEND_P2_SINGLETON_MOD_BYTES) +SPEND_P2_SINGLETON_MOD_HASH = bytes32(SPEND_P2_SINGLETON_MOD_HASH_BYTES) + +DAO_FINISHED_STATE = Program.from_bytes(DAO_FINISHED_STATE_BYTES) +DAO_FINISHED_STATE_HASH = bytes32(DAO_FINISHED_STATE_HASH_BYTES) + +DAO_CAT_TAIL = Program.from_bytes(DAO_CAT_TAIL_BYTES) +DAO_CAT_TAIL_HASH = bytes32(DAO_CAT_TAIL_HASH_BYTES) + +DAO_CAT_LAUNCHER = Program.from_bytes(DAO_CAT_LAUNCHER_BYTES) + +P2_SINGLETON_MOD = Program.from_bytes(P2_SINGLETON_MOD_BYTES) +P2_SINGLETON_MOD_HASH = bytes32(P2_SINGLETON_MOD_HASH_BYTES) + +DAO_UPDATE_PROPOSAL_MOD = Program.from_bytes(DAO_UPDATE_PROPOSAL_MOD_BYTES) +DAO_UPDATE_PROPOSAL_MOD_HASH = bytes32(DAO_UPDATE_PROPOSAL_MOD_HASH_BYTES) + +DAO_CAT_EVE = Program.from_bytes(DAO_CAT_EVE_BYTES) + +P2_SINGLETON_AGGREGATOR_MOD = Program.from_bytes(P2_SINGLETON_AGGREGATOR_MOD_BYTES) log = logging.Logger(__name__) diff --git a/chia/wallet/dao_wallet/dao_wallet.py b/chia/wallet/dao_wallet/dao_wallet.py index 3693d5a8c6a9..ae78444867bb 100644 --- a/chia/wallet/dao_wallet/dao_wallet.py +++ b/chia/wallet/dao_wallet/dao_wallet.py @@ -37,7 +37,6 @@ DAO_FINISHED_STATE, DAO_PROPOSAL_MOD, DAO_TREASURY_MOD, - SINGLETON_LAUNCHER, create_cat_launcher_for_singleton_id, curry_cat_eve, curry_singleton, @@ -64,6 +63,7 @@ ) from chia.wallet.lineage_proof import LineageProof from chia.wallet.singleton import ( + SINGLETON_LAUNCHER_PUZZLE, get_inner_puzzle_from_singleton, get_most_recent_singleton_coin_from_coin_spend, get_singleton_id_from_puzzle, @@ -649,7 +649,7 @@ async def generate_new_dao( # origin is normal coin which creates launcher coin origin = coins.copy().pop() - genesis_launcher_puz = SINGLETON_LAUNCHER + genesis_launcher_puz = SINGLETON_LAUNCHER_PUZZLE # launcher coin contains singleton launcher, launcher coin ID == singleton_id == treasury_id launcher_coin = Coin(origin.name(), genesis_launcher_puz.get_tree_hash(), uint64(1)) @@ -857,7 +857,7 @@ async def generate_new_proposal( return None # origin is normal coin which creates launcher coin origin = coins.copy().pop() - genesis_launcher_puz = SINGLETON_LAUNCHER + genesis_launcher_puz = SINGLETON_LAUNCHER_PUZZLE # launcher coin contains singleton launcher, launcher coin ID == singleton_id == treasury_id launcher_coin = Coin(origin.name(), genesis_launcher_puz.get_tree_hash(), dao_rules.proposal_minimum_amount) diff --git a/chia/wallet/db_wallet/db_wallet_puzzles.py b/chia/wallet/db_wallet/db_wallet_puzzles.py index b2707ea3f198..e9fcccce5463 100644 --- a/chia/wallet/db_wallet/db_wallet_puzzles.py +++ b/chia/wallet/db_wallet/db_wallet_puzzles.py @@ -3,31 +3,31 @@ from collections.abc import Iterator from typing import Union +from chia_puzzles_py.programs import GRAFTROOT_DL_OFFERS as GRAFTROOT_DL_OFFERS_BYTES +from chia_puzzles_py.programs import P2_PARENT as P2_PARENT_BYTES + from chia.types.blockchain_format.program import INFINITE_COST, Program from chia.types.blockchain_format.serialized_program import SerializedProgram from chia.types.blockchain_format.sized_bytes import bytes32 from chia.types.condition_opcodes import ConditionOpcode from chia.util.ints import uint64 -from chia.wallet.nft_wallet.nft_puzzles import NFT_STATE_LAYER_MOD, create_nft_layer_puzzle_with_curry_params -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile - -# from chia.types.condition_opcodes import ConditionOpcode -# from chia.wallet.util.merkle_tree import MerkleTree, TreeType +from chia.wallet.nft_wallet.nft_puzzle_utils import create_nft_layer_puzzle_with_curry_params +from chia.wallet.nft_wallet.nft_puzzles import NFT_STATE_LAYER_MOD +from chia.wallet.singleton import ( + SINGLETON_LAUNCHER_PUZZLE_HASH, + SINGLETON_TOP_LAYER_MOD, +) ACS_MU = Program.to(11) # returns the third argument a.k.a the full solution ACS_MU_PH = ACS_MU.get_tree_hash() -SINGLETON_TOP_LAYER_MOD = load_clvm_maybe_recompile("singleton_top_layer_v1_1.clsp") -SINGLETON_LAUNCHER = load_clvm_maybe_recompile("singleton_launcher.clsp") -GRAFTROOT_DL_OFFERS = load_clvm_maybe_recompile( - "graftroot_dl_offers.clsp", package_or_requirement="chia.data_layer.puzzles" -) -P2_PARENT = load_clvm_maybe_recompile("p2_parent.clsp") +GRAFTROOT_DL_OFFERS = Program.from_bytes(GRAFTROOT_DL_OFFERS_BYTES) +P2_PARENT = Program.from_bytes(P2_PARENT_BYTES) def create_host_fullpuz(innerpuz: Union[Program, bytes32], current_root: bytes32, genesis_id: bytes32) -> Program: db_layer = create_host_layer_puzzle(innerpuz, current_root) mod_hash = SINGLETON_TOP_LAYER_MOD.get_tree_hash() - singleton_struct = Program.to((mod_hash, (genesis_id, SINGLETON_LAUNCHER.get_tree_hash()))) + singleton_struct = Program.to((mod_hash, (genesis_id, SINGLETON_LAUNCHER_PUZZLE_HASH))) return SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, db_layer) @@ -72,7 +72,7 @@ def launch_solution_to_singleton_info(launch_solution: Program) -> tuple[bytes32 def launcher_to_struct(launcher_id: bytes32) -> Program: struct: Program = Program.to( - (SINGLETON_TOP_LAYER_MOD.get_tree_hash(), (launcher_id, SINGLETON_LAUNCHER.get_tree_hash())) + (SINGLETON_TOP_LAYER_MOD.get_tree_hash(), (launcher_id, SINGLETON_LAUNCHER_PUZZLE_HASH)) ) return struct diff --git a/chia/wallet/did_wallet/did_wallet_puzzles.py b/chia/wallet/did_wallet/did_wallet_puzzles.py index c3b8b593cf55..323ad9ff05fd 100644 --- a/chia/wallet/did_wallet/did_wallet_puzzles.py +++ b/chia/wallet/did_wallet/did_wallet_puzzles.py @@ -3,6 +3,7 @@ from collections.abc import Iterator from typing import Optional, Union +from chia_puzzles_py.programs import DID_INNERPUZ, DID_INNERPUZ_HASH, NFT_INTERMEDIATE_LAUNCHER from chia_rs import G1Element from chia.types.blockchain_format.coin import Coin @@ -11,7 +12,6 @@ from chia.types.coin_spend import CoinSpend, make_spend from chia.types.condition_opcodes import ConditionOpcode from chia.util.ints import uint64 -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.singleton import ( SINGLETON_LAUNCHER_PUZZLE_HASH, SINGLETON_LAUNCHER_PUZZLE_HASH_TREE_HASH, @@ -29,14 +29,10 @@ shatree_pair, ) -DID_INNERPUZ_MOD = load_clvm_maybe_recompile( - "did_innerpuz.clsp", package_or_requirement="chia.wallet.did_wallet.puzzles" -) -DID_INNERPUZ_MOD_HASH = DID_INNERPUZ_MOD.get_tree_hash() +DID_INNERPUZ_MOD = Program.from_bytes(DID_INNERPUZ) +DID_INNERPUZ_MOD_HASH = bytes32(DID_INNERPUZ_HASH) DID_INNERPUZ_MOD_HASH_QUOTED = calculate_hash_of_quoted_mod_hash(DID_INNERPUZ_MOD_HASH) -INTERMEDIATE_LAUNCHER_MOD = load_clvm_maybe_recompile( - "nft_intermediate_launcher.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" -) +INTERMEDIATE_LAUNCHER_MOD = Program.from_bytes(NFT_INTERMEDIATE_LAUNCHER) def create_innerpuz( diff --git a/chia/wallet/did_wallet/puzzles/__init__.py b/chia/wallet/did_wallet/puzzles/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/chia/wallet/did_wallet/puzzles/did_innerpuz.clsp b/chia/wallet/did_wallet/puzzles/did_innerpuz.clsp deleted file mode 100644 index 0eba28e5ce28..000000000000 --- a/chia/wallet/did_wallet/puzzles/did_innerpuz.clsp +++ /dev/null @@ -1,135 +0,0 @@ -; The DID innerpuzzle is designed to sit inside the singleton layer and provide functionality related to being an identity. -; At the moment the two pieces of functionality are recovery and message creation. -; A DID's ID is it's Singleton ID -; Recovery is based around having a list of known other DIDs which can send messages approving you change the innerpuzzle of your DID singleton - -(mod - ( - INNER_PUZZLE ; Standard P2 inner puzzle, used to record the ownership of the DID. - RECOVERY_DID_LIST_HASH ; the list of DIDs that can send messages to you for recovery we store only the hash so that we don't have to reveal every time we make a message spend - NUM_VERIFICATIONS_REQUIRED ; how many of the above list are required for a recovery - SINGLETON_STRUCT ; my singleton_struct, formerly a Truth - ((SINGLETON_MOD_HASH, (LAUNCHER_ID, LAUNCHER_PUZZLE_HASH))) - METADATA ; Customized metadata, e.g KYC info - mode ; this indicates which spend mode we want. 0. Recovery mode 1. Run INNER_PUZZLE with p2_solution - my_amount_or_inner_solution ; In mode 0, we use this to recover our coin and assert it is our actual amount - ; In mode 1 this is the solution of the inner P2 puzzle, only required in the create message mode and transfer mode. - new_inner_puzhash ; In recovery mode, this will be the new wallet DID puzzle hash - parent_innerpuzhash_amounts_for_recovery_ids ; during a recovery we need extra information about our recovery list coins - pubkey ; this is the new pubkey used for a recovery - recovery_list_reveal ; this is the reveal of the stored list of DIDs approved for recovery - my_id ; my coin ID - ) - ;message is the new puzzle in the recovery and standard spend cases - - ;MOD_HASH, MY_PUBKEY, RECOVERY_DID_LIST_HASH are curried into the puzzle - ;EXAMPLE SOLUTION (0xcafef00d 0x12341234 0x923bf9a7856b19d335a65f12d68957d497e1f0c16c0e14baf6d120e60753a1ce 2 1 100 (q "source code") 0xdeadbeef 0xcafef00d ((0xdadadada 0xdad5dad5 200) () (0xfafafafa 0xfaf5faf5 200)) 0xfadeddab (0x22222222 0x33333333 0x44444444)) - - (include condition_codes.clib) - (include curry-and-treehash.clib) - - ; takes a lisp tree and returns the hash of it - (defun sha256tree1 (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE) - ) - ) - - ; recovery message module - gets values curried in to make the puzzle - (defun make_message_puzzle (recovering_coin newpuz pubkey) - (qq (q . (((unquote CREATE_COIN_ANNOUNCEMENT) (unquote recovering_coin)) ((unquote AGG_SIG_UNSAFE) (unquote pubkey) (unquote newpuz))))) - ) - - ; this function creates the assert announcement for each message coin approving a recovery - (defun-inline create_consume_message (coin_id my_id new_innerpuz pubkey) - (list ASSERT_COIN_ANNOUNCEMENT (sha256 (sha256 coin_id (sha256tree1 (make_message_puzzle my_id new_innerpuz pubkey))) my_id)) - ) - - ; this function calculates a coin ID given the inner puzzle and singleton information - (defun create_coin_ID_for_recovery (SINGLETON_STRUCT launcher_id parent innerpuzhash amount) - (sha256 parent (calculate_full_puzzle_hash (c (f SINGLETON_STRUCT) (c launcher_id (r (r SINGLETON_STRUCT)))) innerpuzhash) amount) - ) - - - ; return the full puzzlehash for a singleton with the innerpuzzle curried in - ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib - (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (f SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree1 SINGLETON_STRUCT) - ) - ) - - ; this loops over our identities to check list, and checks if we have been given parent information for this identity - ; the reason for this is because we might only require 3/5 of the IDs give approval messages for a recovery - ; if we have the information for an identity then we create a consume message using that information - - (defun check_messages_from_identities (SINGLETON_STRUCT num_verifications_required identities my_id new_puz parent_innerpuzhash_amounts_for_recovery_ids pubkey num_verifications) - (if identities - (if (f parent_innerpuzhash_amounts_for_recovery_ids) - ; if we have parent information then we should create a consume coin condition - (c - (create_consume_message - ; create coin_id from DID - (create_coin_ID_for_recovery - SINGLETON_STRUCT - (f identities) - (f (f parent_innerpuzhash_amounts_for_recovery_ids)) - (f (r (f parent_innerpuzhash_amounts_for_recovery_ids))) - (f (r (r (f parent_innerpuzhash_amounts_for_recovery_ids))))) - my_id - new_puz - pubkey - ) - (check_messages_from_identities - SINGLETON_STRUCT - num_verifications_required - (r identities) - my_id - new_puz - (r parent_innerpuzhash_amounts_for_recovery_ids) - pubkey - (+ num_verifications 1) - ) - ) - ; if no parent information found for this identity, move on to next in list - (check_messages_from_identities - SINGLETON_STRUCT - (r identities) - my_id - new_puz - (r parent_innerpuzhash_amounts_for_recovery_ids) - pubkey - num_verifications - ) - ) - ;if we're out of identites to check for, check we have enough - (if (> num_verifications (- num_verifications_required 1)) - (list (list AGG_SIG_UNSAFE pubkey new_puz) ) - (x) - ) - ) - ) - - ;Spend modes: - ;0 = recovery - ;1 = run the INNER_PUZZLE - - ;MAIN - (if mode - ; mode 1 - run INNER_PUZZLE - (a INNER_PUZZLE my_amount_or_inner_solution) - - ; mode 0 - recovery - (if (all (= (sha256tree1 recovery_list_reveal) RECOVERY_DID_LIST_HASH) (> NUM_VERIFICATIONS_REQUIRED 0)) - (c (list ASSERT_MY_AMOUNT my_amount_or_inner_solution) - (c (list CREATE_COIN new_inner_puzhash my_amount_or_inner_solution (list new_inner_puzhash)) - (c (list ASSERT_MY_COIN_ID my_id) - (check_messages_from_identities SINGLETON_STRUCT NUM_VERIFICATIONS_REQUIRED recovery_list_reveal my_id new_inner_puzhash parent_innerpuzhash_amounts_for_recovery_ids pubkey 0) - ) - ) - ) - (x) - ) - ) -) diff --git a/chia/wallet/did_wallet/puzzles/did_innerpuz.clsp.hex b/chia/wallet/did_wallet/puzzles/did_innerpuz.clsp.hex deleted file mode 100644 index c869e6dedc0f..000000000000 --- a/chia/wallet/did_wallet/puzzles/did_innerpuz.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff81bfffff01ff02ff05ff82017f80ffff01ff02ffff03ffff22ffff09ffff02ff7effff04ff02ffff04ff8217ffff80808080ff0b80ffff15ff17ff808080ffff01ff04ffff04ff28ffff04ff82017fff808080ffff04ffff04ff34ffff04ff8202ffffff04ff82017fffff04ffff04ff8202ffff8080ff8080808080ffff04ffff04ff38ffff04ff822fffff808080ffff02ff26ffff04ff02ffff04ff2fffff04ff17ffff04ff8217ffffff04ff822fffffff04ff8202ffffff04ff8205ffffff04ff820bffffff01ff8080808080808080808080808080ffff01ff088080ff018080ff0180ffff04ffff01ffffffff313dff4946ffff0233ff3c04ffffff0101ff02ff02ffff03ff05ffff01ff02ff3affff04ff02ffff04ff0dffff04ffff0bff2affff0bff22ff3c80ffff0bff2affff0bff2affff0bff22ff3280ff0980ffff0bff2aff0bffff0bff22ff8080808080ff8080808080ffff010b80ff0180ffffff02ffff03ff17ffff01ff02ffff03ff82013fffff01ff04ffff04ff30ffff04ffff0bffff0bffff02ff36ffff04ff02ffff04ff05ffff04ff27ffff04ff82023fffff04ff82053fffff04ff820b3fff8080808080808080ffff02ff7effff04ff02ffff04ffff02ff2effff04ff02ffff04ff2fffff04ff5fffff04ff82017fff808080808080ff8080808080ff2f80ff808080ffff02ff26ffff04ff02ffff04ff05ffff04ff0bffff04ff37ffff04ff2fffff04ff5fffff04ff8201bfffff04ff82017fffff04ffff10ff8202ffffff010180ff808080808080808080808080ffff01ff02ff26ffff04ff02ffff04ff05ffff04ff37ffff04ff2fffff04ff5fffff04ff8201bfffff04ff82017fffff04ff8202ffff8080808080808080808080ff0180ffff01ff02ffff03ffff15ff8202ffffff11ff0bffff01018080ffff01ff04ffff04ff20ffff04ff82017fffff04ff5fff80808080ff8080ffff01ff088080ff018080ff0180ff0bff17ffff02ff5effff04ff02ffff04ff09ffff04ff2fffff04ffff02ff7effff04ff02ffff04ffff04ff09ffff04ff0bff1d8080ff80808080ff808080808080ff5f80ffff04ffff0101ffff04ffff04ff2cffff04ff05ff808080ffff04ffff04ff20ffff04ff17ffff04ff0bff80808080ff80808080ffff0bff2affff0bff22ff2480ffff0bff2affff0bff2affff0bff22ff3280ff0580ffff0bff2affff02ff3affff04ff02ffff04ff07ffff04ffff0bff22ff2280ff8080808080ffff0bff22ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff7effff04ff02ffff04ff09ff80808080ffff02ff7effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/nft_wallet/metadata_outer_puzzle.py b/chia/wallet/nft_wallet/metadata_outer_puzzle.py index 0545227c007f..ccab8ffcca06 100644 --- a/chia/wallet/nft_wallet/metadata_outer_puzzle.py +++ b/chia/wallet/nft_wallet/metadata_outer_puzzle.py @@ -5,15 +5,13 @@ from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 +from chia.wallet.nft_wallet.nft_puzzles import ( + NFT_STATE_LAYER_MOD, + NFT_STATE_LAYER_MOD_HASH, +) from chia.wallet.puzzle_drivers import PuzzleInfo, Solver -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.uncurried_puzzle import UncurriedPuzzle, uncurry_puzzle -NFT_STATE_LAYER_MOD = load_clvm_maybe_recompile( - "nft_state_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" -) -NFT_STATE_LAYER_MOD_HASH = NFT_STATE_LAYER_MOD.get_tree_hash() - def match_metadata_layer_puzzle(puzzle: UncurriedPuzzle) -> tuple[bool, list[Program]]: if puzzle.mod == NFT_STATE_LAYER_MOD: diff --git a/chia/wallet/nft_wallet/nft_info.py b/chia/wallet/nft_wallet/nft_info.py index 1d54458ab5b3..847016997038 100644 --- a/chia/wallet/nft_wallet/nft_info.py +++ b/chia/wallet/nft_wallet/nft_info.py @@ -9,9 +9,8 @@ from chia.util.ints import uint16, uint32, uint64 from chia.util.streamable import Streamable, streamable from chia.wallet.lineage_proof import LineageProof -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile +from chia.wallet.singleton import SINGLETON_LAUNCHER_PUZZLE_HASH -LAUNCHER_PUZZLE = load_clvm_maybe_recompile("singleton_launcher.clsp") IN_TRANSACTION_STATUS = "IN_TRANSACTION" DEFAULT_STATUS = "DEFAULT" @@ -85,7 +84,7 @@ class NFTInfo(Streamable): minter_did: Optional[bytes32] = None """DID of the NFT minter""" - launcher_puzhash: bytes32 = LAUNCHER_PUZZLE.get_tree_hash() + launcher_puzhash: bytes32 = SINGLETON_LAUNCHER_PUZZLE_HASH """Puzzle hash of the singleton launcher in hex""" off_chain_metadata: Optional[str] = None diff --git a/chia/wallet/nft_wallet/nft_puzzle_utils.py b/chia/wallet/nft_wallet/nft_puzzle_utils.py new file mode 100644 index 000000000000..debdde657e37 --- /dev/null +++ b/chia/wallet/nft_wallet/nft_puzzle_utils.py @@ -0,0 +1,293 @@ +from __future__ import annotations + +import logging +from typing import Any, Literal, Optional, Union + +from clvm_tools.binutils import disassemble + +from chia.types.blockchain_format.program import Program +from chia.types.blockchain_format.serialized_program import SerializedProgram +from chia.types.blockchain_format.sized_bytes import bytes32 +from chia.util.bech32m import encode_puzzle_hash +from chia.util.ints import uint16, uint64 +from chia.wallet.nft_wallet.nft_info import NFTCoinInfo, NFTInfo +from chia.wallet.nft_wallet.nft_puzzles import ( + NFT_OWNERSHIP_LAYER, + NFT_OWNERSHIP_LAYER_HASH, + NFT_STATE_LAYER_MOD, + NFT_STATE_LAYER_MOD_HASH, + NFT_TRANSFER_PROGRAM_DEFAULT, +) +from chia.wallet.nft_wallet.uncurry_nft import UncurriedNFT +from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import solution_for_conditions +from chia.wallet.singleton import ( + SINGLETON_LAUNCHER_PUZZLE_HASH, + SINGLETON_TOP_LAYER_MOD, + SINGLETON_TOP_LAYER_MOD_HASH, +) +from chia.wallet.util.address_type import AddressType + +log = logging.getLogger(__name__) + + +def create_nft_layer_puzzle_with_curry_params( + metadata: Program, metadata_updater_hash: bytes32, inner_puzzle: Program +) -> Program: + """Curries params into nft_state_layer.clsp + + Args to curry: + NFT_STATE_LAYER_MOD_HASH + METADATA + METADATA_UPDATER_PUZZLE_HASH + INNER_PUZZLE""" + return NFT_STATE_LAYER_MOD.curry(NFT_STATE_LAYER_MOD_HASH, metadata, metadata_updater_hash, inner_puzzle) + + +def create_full_puzzle_with_nft_puzzle(singleton_id: bytes32, inner_puzzle: Program) -> Program: + if log.isEnabledFor(logging.DEBUG): + log.debug("Creating full NFT puzzle with inner puzzle: \n%r\n%r", singleton_id, inner_puzzle.get_tree_hash()) + singleton_struct = Program.to((SINGLETON_TOP_LAYER_MOD_HASH, (singleton_id, SINGLETON_LAUNCHER_PUZZLE_HASH))) + + full_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, inner_puzzle) + if log.isEnabledFor(logging.DEBUG): + log.debug("Created NFT full puzzle with inner: %s", full_puzzle.get_tree_hash()) + return full_puzzle + + +def create_full_puzzle( + singleton_id: bytes32, metadata: Program, metadata_updater_puzhash: bytes32, inner_puzzle: Program +) -> Program: + if log.isEnabledFor(logging.DEBUG): + log.debug( + "Creating full NFT puzzle with: \n%r\n%r\n%r\n%r", + singleton_id, + metadata.get_tree_hash(), + metadata_updater_puzhash, + inner_puzzle.get_tree_hash(), + ) + singleton_struct = Program.to((SINGLETON_TOP_LAYER_MOD_HASH, (singleton_id, SINGLETON_LAUNCHER_PUZZLE_HASH))) + singleton_inner_puzzle = create_nft_layer_puzzle_with_curry_params(metadata, metadata_updater_puzhash, inner_puzzle) + + full_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, singleton_inner_puzzle) + if log.isEnabledFor(logging.DEBUG): + log.debug("Created NFT full puzzle: %s", full_puzzle.get_tree_hash()) + return full_puzzle + + +async def get_nft_info_from_puzzle(nft_coin_info: NFTCoinInfo, config: dict[str, Any]) -> NFTInfo: + """ + Extract NFT info from a full puzzle + :param nft_coin_info NFTCoinInfo in local database + :param config Wallet config + :param ignore_size_limit Ignore the off-chain metadata loading size limit + :return: NFTInfo + """ + uncurried_nft: Optional[UncurriedNFT] = UncurriedNFT.uncurry(*nft_coin_info.full_puzzle.uncurry()) + assert uncurried_nft is not None + data_uris: list[str] = [] + + for uri in uncurried_nft.data_uris.as_python(): + data_uris.append(str(uri, "utf-8")) + meta_uris: list[str] = [] + for uri in uncurried_nft.meta_uris.as_python(): + meta_uris.append(str(uri, "utf-8")) + license_uris: list[str] = [] + for uri in uncurried_nft.license_uris.as_python(): + license_uris.append(str(uri, "utf-8")) + off_chain_metadata: Optional[str] = None + nft_info = NFTInfo( + encode_puzzle_hash(uncurried_nft.singleton_launcher_id, prefix=AddressType.NFT.hrp(config=config)), + uncurried_nft.singleton_launcher_id, + nft_coin_info.coin.name(), + nft_coin_info.latest_height, + uncurried_nft.owner_did, + uncurried_nft.trade_price_percentage, + uncurried_nft.royalty_address, + data_uris, + uncurried_nft.data_hash.as_python(), + meta_uris, + uncurried_nft.meta_hash.as_python(), + license_uris, + uncurried_nft.license_hash.as_python(), + uint64(uncurried_nft.edition_total.as_int()), + uint64(uncurried_nft.edition_number.as_int()), + uncurried_nft.metadata_updater_hash.as_python(), + disassemble(uncurried_nft.metadata), + nft_coin_info.mint_height, + uncurried_nft.supports_did, + uncurried_nft.p2_puzzle.get_tree_hash(), + nft_coin_info.pending_transaction, + nft_coin_info.minter_did, + off_chain_metadata=off_chain_metadata, + ) + return nft_info + + +def metadata_to_program(metadata: dict[bytes, Any]) -> Program: + """ + Convert the metadata dict to a Chialisp program + :param metadata: User defined metadata + :return: Chialisp program + """ + kv_list = [] + for key, value in metadata.items(): + kv_list.append((key, value)) + program: Program = Program.to(kv_list) + return program + + +def nft_program_to_metadata(program: Program) -> dict[bytes, Any]: + """ + Convert a program to a metadata dict + :param program: Chialisp program contains the metadata + :return: Metadata dict + """ + metadata = {} + for kv_pair in program.as_iter(): + metadata[kv_pair.first().as_atom()] = kv_pair.rest().as_python() + return metadata + + +def prepend_value(key: bytes, value: Program, metadata: dict[bytes, Any]) -> None: + """ + Prepend a value to a list in the metadata + :param key: Key of the field + :param value: Value want to add + :param metadata: Metadata + :return: + """ + if value != Program.to(0): + if metadata[key] == b"": + metadata[key] = [value.as_python()] + else: + metadata[key].insert(0, value.as_python()) + + +def update_metadata(metadata: Program, update_condition: Program) -> Program: + """ + Apply conditions of metadata updater to the previous metadata + :param metadata: Previous metadata + :param update_condition: Update metadata conditions + :return: Updated metadata + """ + new_metadata: dict[bytes, Any] = nft_program_to_metadata(metadata) + uri: Program = update_condition.rest().rest().first() + prepend_value(uri.first().as_python(), uri.rest(), new_metadata) + return metadata_to_program(new_metadata) + + +def construct_ownership_layer( + current_owner: Optional[bytes32], + transfer_program: Program, + inner_puzzle: Program, +) -> Program: + return NFT_OWNERSHIP_LAYER.curry(NFT_OWNERSHIP_LAYER_HASH, current_owner, transfer_program, inner_puzzle) + + +def create_ownership_layer_puzzle( + nft_id: bytes32, + did_id: bytes, + p2_puzzle: Program, + percentage: uint16, + royalty_puzzle_hash: Optional[bytes32] = None, +) -> Program: + log.debug( + "Creating ownership layer puzzle with NFT_ID: %s DID_ID: %s Royalty_Percentage: %d P2_puzzle: %s", + nft_id.hex(), + did_id, + percentage, + p2_puzzle, + ) + singleton_struct = Program.to((SINGLETON_TOP_LAYER_MOD_HASH, (nft_id, SINGLETON_LAUNCHER_PUZZLE_HASH))) + if not royalty_puzzle_hash: + royalty_puzzle_hash = p2_puzzle.get_tree_hash() + transfer_program = NFT_TRANSFER_PROGRAM_DEFAULT.curry(singleton_struct, royalty_puzzle_hash, percentage) + nft_inner_puzzle = p2_puzzle + + nft_ownership_layer_puzzle = construct_ownership_layer( + bytes32(did_id) if did_id else None, transfer_program, nft_inner_puzzle + ) + return nft_ownership_layer_puzzle + + +def create_ownership_layer_transfer_solution( + new_did: bytes, new_did_inner_hash: bytes, trade_prices_list: list[list[int]], new_puzhash: bytes32 +) -> Program: + log.debug( + "Creating a transfer solution with: DID:%s Inner_puzhash:%s trade_price:%s puzhash:%s", + new_did.hex(), + new_did_inner_hash.hex(), + str(trade_prices_list), + new_puzhash.hex(), + ) + condition_list = [[51, new_puzhash, 1, [new_puzhash]], [-10, new_did, trade_prices_list, new_did_inner_hash]] + log.debug("Condition list raw: %r", condition_list) + solution = Program.to([[solution_for_conditions(condition_list)]]) + log.debug("Generated transfer solution: %s", solution) + return solution + + +def get_metadata_and_phs(unft: UncurriedNFT, solution: SerializedProgram) -> tuple[Program, bytes32]: + conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution.to_program())) + metadata = unft.metadata + puzhash_for_derivation: Optional[bytes32] = None + for condition in conditions.as_iter(): + if condition.list_len() < 2: + # invalid condition + continue + condition_code = condition.first().as_int() + log.debug("Checking condition code: %r", condition_code) + if condition_code == -24: + # metadata update + metadata = update_metadata(metadata, condition) + metadata = Program.to(metadata) + elif condition_code == 51: + atom = condition.rest().rest().first().as_int() + + if atom == 1: + # destination puzhash + if puzhash_for_derivation is not None: + # ignore duplicated create coin conditions + continue + memo = bytes32(condition.at("rrrff").as_atom()) + puzhash_for_derivation = memo + log.debug("Got back puzhash from solution: %s", puzhash_for_derivation) + assert puzhash_for_derivation + return metadata, puzhash_for_derivation + + +def recurry_nft_puzzle(unft: UncurriedNFT, solution: Program, new_inner_puzzle: Program) -> Program: + log.debug("Generating NFT puzzle with ownership support: %s", disassemble(solution)) + conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution)) + new_did_id = unft.owner_did + new_puzhash = None + for condition in conditions.as_iter(): + if condition.first().as_int() == -10: + # this is the change owner magic condition + atom = condition.at("rf").atom + if atom is None or atom == b"": + new_did_id = None + else: + new_did_id = bytes32(atom) + elif condition.first().as_int() == 51: + new_puzhash = condition.at("rf").atom + # assert new_puzhash and new_did_id + log.debug(f"Found NFT puzzle details: {new_did_id!r} {new_puzhash!r}") + assert unft.transfer_program + new_ownership_puzzle = construct_ownership_layer(new_did_id, unft.transfer_program, new_inner_puzzle) + + return new_ownership_puzzle + + +def get_new_owner_did(unft: UncurriedNFT, solution: Program) -> Union[Literal[b""], bytes32, None]: + conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution)) + new_did_id: Union[Literal[b""], bytes32, None] = None + for condition in conditions.as_iter(): + if condition.first().as_int() == -10: + # this is the change owner magic condition + atom = condition.at("rf").as_atom() + if atom == b"": + new_did_id = b"" + else: + new_did_id = bytes32(atom) + return new_did_id diff --git a/chia/wallet/nft_wallet/nft_puzzles.py b/chia/wallet/nft_wallet/nft_puzzles.py index fe49e50dec49..67de87c070c9 100644 --- a/chia/wallet/nft_wallet/nft_puzzles.py +++ b/chia/wallet/nft_wallet/nft_puzzles.py @@ -1,305 +1,28 @@ from __future__ import annotations -import logging -from typing import Any, Literal, Optional, Union - -from clvm_tools.binutils import disassemble - -from chia.types.blockchain_format.program import Program -from chia.types.blockchain_format.serialized_program import SerializedProgram -from chia.types.blockchain_format.sized_bytes import bytes32 -from chia.util.bech32m import encode_puzzle_hash -from chia.util.ints import uint16, uint64 -from chia.wallet.nft_wallet.nft_info import NFTCoinInfo, NFTInfo -from chia.wallet.nft_wallet.uncurry_nft import UncurriedNFT -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile -from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import solution_for_conditions -from chia.wallet.util.address_type import AddressType - -log = logging.getLogger(__name__) -SINGLETON_TOP_LAYER_MOD = load_clvm_maybe_recompile("singleton_top_layer_v1_1.clsp") -LAUNCHER_PUZZLE = load_clvm_maybe_recompile("singleton_launcher.clsp") -NFT_STATE_LAYER_MOD = load_clvm_maybe_recompile( - "nft_state_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" -) -LAUNCHER_PUZZLE_HASH = LAUNCHER_PUZZLE.get_tree_hash() -SINGLETON_MOD_HASH = SINGLETON_TOP_LAYER_MOD.get_tree_hash() -NFT_STATE_LAYER_MOD_HASH = NFT_STATE_LAYER_MOD.get_tree_hash() -NFT_METADATA_UPDATER = load_clvm_maybe_recompile( - "nft_metadata_updater_default.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" +from chia_puzzles_py.programs import ( + NFT_INTERMEDIATE_LAUNCHER, + NFT_METADATA_UPDATER_DEFAULT, + NFT_METADATA_UPDATER_DEFAULT_HASH, + NFT_OWNERSHIP_TRANSFER_PROGRAM_ONE_WAY_CLAIM_WITH_ROYALTIES, + NFT_STATE_LAYER, + NFT_STATE_LAYER_HASH, ) -NFT_OWNERSHIP_LAYER = load_clvm_maybe_recompile( - "nft_ownership_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" +from chia_puzzles_py.programs import ( + NFT_OWNERSHIP_LAYER as NFT_OWNERSHIP_LAYER_BYTES, ) -NFT_OWNERSHIP_LAYER_HASH = NFT_OWNERSHIP_LAYER.get_tree_hash() -NFT_TRANSFER_PROGRAM_DEFAULT = load_clvm_maybe_recompile( - "nft_ownership_transfer_program_one_way_claim_with_royalties.clsp", - package_or_requirement="chia.wallet.nft_wallet.puzzles", +from chia_puzzles_py.programs import ( + NFT_OWNERSHIP_LAYER_HASH as NFT_OWNERSHIP_LAYER_HASH_BYTES, ) -STANDARD_PUZZLE_MOD = load_clvm_maybe_recompile("p2_delegated_puzzle_or_hidden_puzzle.clsp") -INTERMEDIATE_LAUNCHER_MOD = load_clvm_maybe_recompile( - "nft_intermediate_launcher.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" -) - - -def create_nft_layer_puzzle_with_curry_params( - metadata: Program, metadata_updater_hash: bytes32, inner_puzzle: Program -) -> Program: - """Curries params into nft_state_layer.clsp - - Args to curry: - NFT_STATE_LAYER_MOD_HASH - METADATA - METADATA_UPDATER_PUZZLE_HASH - INNER_PUZZLE""" - return NFT_STATE_LAYER_MOD.curry(NFT_STATE_LAYER_MOD_HASH, metadata, metadata_updater_hash, inner_puzzle) - - -def create_full_puzzle_with_nft_puzzle(singleton_id: bytes32, inner_puzzle: Program) -> Program: - if log.isEnabledFor(logging.DEBUG): - log.debug("Creating full NFT puzzle with inner puzzle: \n%r\n%r", singleton_id, inner_puzzle.get_tree_hash()) - singleton_struct = Program.to((SINGLETON_MOD_HASH, (singleton_id, LAUNCHER_PUZZLE_HASH))) - - full_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, inner_puzzle) - if log.isEnabledFor(logging.DEBUG): - log.debug("Created NFT full puzzle with inner: %s", full_puzzle.get_tree_hash()) - return full_puzzle - - -def create_full_puzzle( - singleton_id: bytes32, metadata: Program, metadata_updater_puzhash: bytes32, inner_puzzle: Program -) -> Program: - if log.isEnabledFor(logging.DEBUG): - log.debug( - "Creating full NFT puzzle with: \n%r\n%r\n%r\n%r", - singleton_id, - metadata.get_tree_hash(), - metadata_updater_puzhash, - inner_puzzle.get_tree_hash(), - ) - singleton_struct = Program.to((SINGLETON_MOD_HASH, (singleton_id, LAUNCHER_PUZZLE_HASH))) - singleton_inner_puzzle = create_nft_layer_puzzle_with_curry_params(metadata, metadata_updater_puzhash, inner_puzzle) - - full_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, singleton_inner_puzzle) - if log.isEnabledFor(logging.DEBUG): - log.debug("Created NFT full puzzle: %s", full_puzzle.get_tree_hash()) - return full_puzzle - - -async def get_nft_info_from_puzzle(nft_coin_info: NFTCoinInfo, config: dict[str, Any]) -> NFTInfo: - """ - Extract NFT info from a full puzzle - :param nft_coin_info NFTCoinInfo in local database - :param config Wallet config - :param ignore_size_limit Ignore the off-chain metadata loading size limit - :return: NFTInfo - """ - uncurried_nft: Optional[UncurriedNFT] = UncurriedNFT.uncurry(*nft_coin_info.full_puzzle.uncurry()) - assert uncurried_nft is not None - data_uris: list[str] = [] - - for uri in uncurried_nft.data_uris.as_python(): - data_uris.append(str(uri, "utf-8")) - meta_uris: list[str] = [] - for uri in uncurried_nft.meta_uris.as_python(): - meta_uris.append(str(uri, "utf-8")) - license_uris: list[str] = [] - for uri in uncurried_nft.license_uris.as_python(): - license_uris.append(str(uri, "utf-8")) - off_chain_metadata: Optional[str] = None - nft_info = NFTInfo( - encode_puzzle_hash(uncurried_nft.singleton_launcher_id, prefix=AddressType.NFT.hrp(config=config)), - uncurried_nft.singleton_launcher_id, - nft_coin_info.coin.name(), - nft_coin_info.latest_height, - uncurried_nft.owner_did, - uncurried_nft.trade_price_percentage, - uncurried_nft.royalty_address, - data_uris, - uncurried_nft.data_hash.as_python(), - meta_uris, - uncurried_nft.meta_hash.as_python(), - license_uris, - uncurried_nft.license_hash.as_python(), - uint64(uncurried_nft.edition_total.as_int()), - uint64(uncurried_nft.edition_number.as_int()), - uncurried_nft.metadata_updater_hash.as_python(), - disassemble(uncurried_nft.metadata), - nft_coin_info.mint_height, - uncurried_nft.supports_did, - uncurried_nft.p2_puzzle.get_tree_hash(), - nft_coin_info.pending_transaction, - nft_coin_info.minter_did, - off_chain_metadata=off_chain_metadata, - ) - return nft_info - - -def metadata_to_program(metadata: dict[bytes, Any]) -> Program: - """ - Convert the metadata dict to a Chialisp program - :param metadata: User defined metadata - :return: Chialisp program - """ - kv_list = [] - for key, value in metadata.items(): - kv_list.append((key, value)) - program: Program = Program.to(kv_list) - return program - - -def nft_program_to_metadata(program: Program) -> dict[bytes, Any]: - """ - Convert a program to a metadata dict - :param program: Chialisp program contains the metadata - :return: Metadata dict - """ - metadata = {} - for kv_pair in program.as_iter(): - metadata[kv_pair.first().as_atom()] = kv_pair.rest().as_python() - return metadata - - -def prepend_value(key: bytes, value: Program, metadata: dict[bytes, Any]) -> None: - """ - Prepend a value to a list in the metadata - :param key: Key of the field - :param value: Value want to add - :param metadata: Metadata - :return: - """ - if value != Program.to(0): - if metadata[key] == b"": - metadata[key] = [value.as_python()] - else: - metadata[key].insert(0, value.as_python()) - - -def update_metadata(metadata: Program, update_condition: Program) -> Program: - """ - Apply conditions of metadata updater to the previous metadata - :param metadata: Previous metadata - :param update_condition: Update metadata conditions - :return: Updated metadata - """ - new_metadata: dict[bytes, Any] = nft_program_to_metadata(metadata) - uri: Program = update_condition.rest().rest().first() - prepend_value(uri.first().as_python(), uri.rest(), new_metadata) - return metadata_to_program(new_metadata) - - -def construct_ownership_layer( - current_owner: Optional[bytes32], - transfer_program: Program, - inner_puzzle: Program, -) -> Program: - return NFT_OWNERSHIP_LAYER.curry(NFT_OWNERSHIP_LAYER_HASH, current_owner, transfer_program, inner_puzzle) - - -def create_ownership_layer_puzzle( - nft_id: bytes32, - did_id: bytes, - p2_puzzle: Program, - percentage: uint16, - royalty_puzzle_hash: Optional[bytes32] = None, -) -> Program: - log.debug( - "Creating ownership layer puzzle with NFT_ID: %s DID_ID: %s Royalty_Percentage: %d P2_puzzle: %s", - nft_id.hex(), - did_id, - percentage, - p2_puzzle, - ) - singleton_struct = Program.to((SINGLETON_MOD_HASH, (nft_id, LAUNCHER_PUZZLE_HASH))) - if not royalty_puzzle_hash: - royalty_puzzle_hash = p2_puzzle.get_tree_hash() - transfer_program = NFT_TRANSFER_PROGRAM_DEFAULT.curry(singleton_struct, royalty_puzzle_hash, percentage) - nft_inner_puzzle = p2_puzzle - - nft_ownership_layer_puzzle = construct_ownership_layer( - bytes32(did_id) if did_id else None, transfer_program, nft_inner_puzzle - ) - return nft_ownership_layer_puzzle - - -def create_ownership_layer_transfer_solution( - new_did: bytes, new_did_inner_hash: bytes, trade_prices_list: list[list[int]], new_puzhash: bytes32 -) -> Program: - log.debug( - "Creating a transfer solution with: DID:%s Inner_puzhash:%s trade_price:%s puzhash:%s", - new_did.hex(), - new_did_inner_hash.hex(), - str(trade_prices_list), - new_puzhash.hex(), - ) - condition_list = [[51, new_puzhash, 1, [new_puzhash]], [-10, new_did, trade_prices_list, new_did_inner_hash]] - log.debug("Condition list raw: %r", condition_list) - solution = Program.to([[solution_for_conditions(condition_list)]]) - log.debug("Generated transfer solution: %s", solution) - return solution - - -def get_metadata_and_phs(unft: UncurriedNFT, solution: SerializedProgram) -> tuple[Program, bytes32]: - conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution.to_program())) - metadata = unft.metadata - puzhash_for_derivation: Optional[bytes32] = None - for condition in conditions.as_iter(): - if condition.list_len() < 2: - # invalid condition - continue - condition_code = condition.first().as_int() - log.debug("Checking condition code: %r", condition_code) - if condition_code == -24: - # metadata update - metadata = update_metadata(metadata, condition) - metadata = Program.to(metadata) - elif condition_code == 51: - atom = condition.rest().rest().first().as_int() - - if atom == 1: - # destination puzhash - if puzhash_for_derivation is not None: - # ignore duplicated create coin conditions - continue - memo = bytes32(condition.at("rrrff").as_atom()) - puzhash_for_derivation = memo - log.debug("Got back puzhash from solution: %s", puzhash_for_derivation) - assert puzhash_for_derivation - return metadata, puzhash_for_derivation - - -def recurry_nft_puzzle(unft: UncurriedNFT, solution: Program, new_inner_puzzle: Program) -> Program: - log.debug("Generating NFT puzzle with ownership support: %s", disassemble(solution)) - conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution)) - new_did_id = unft.owner_did - new_puzhash = None - for condition in conditions.as_iter(): - if condition.first().as_int() == -10: - # this is the change owner magic condition - atom = condition.at("rf").atom - if atom is None or atom == b"": - new_did_id = None - else: - new_did_id = bytes32(atom) - elif condition.first().as_int() == 51: - new_puzhash = condition.at("rf").atom - # assert new_puzhash and new_did_id - log.debug(f"Found NFT puzzle details: {new_did_id!r} {new_puzhash!r}") - assert unft.transfer_program - new_ownership_puzzle = construct_ownership_layer(new_did_id, unft.transfer_program, new_inner_puzzle) - - return new_ownership_puzzle +from chia.types.blockchain_format.program import Program +from chia.types.blockchain_format.sized_bytes import bytes32 -def get_new_owner_did(unft: UncurriedNFT, solution: Program) -> Union[Literal[b""], bytes32, None]: - conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution)) - new_did_id: Union[Literal[b""], bytes32, None] = None - for condition in conditions.as_iter(): - if condition.first().as_int() == -10: - # this is the change owner magic condition - atom = condition.at("rf").as_atom() - if atom == b"": - new_did_id = b"" - else: - new_did_id = bytes32(atom) - return new_did_id +NFT_STATE_LAYER_MOD = Program.from_bytes(NFT_STATE_LAYER) +NFT_STATE_LAYER_MOD_HASH = bytes32(NFT_STATE_LAYER_HASH) +NFT_METADATA_UPDATER = Program.from_bytes(NFT_METADATA_UPDATER_DEFAULT) +NFT_METADATA_UPDATER_HASH = bytes32(NFT_METADATA_UPDATER_DEFAULT_HASH) +NFT_OWNERSHIP_LAYER = Program.from_bytes(NFT_OWNERSHIP_LAYER_BYTES) +NFT_OWNERSHIP_LAYER_HASH = bytes32(NFT_OWNERSHIP_LAYER_HASH_BYTES) +NFT_TRANSFER_PROGRAM_DEFAULT = Program.from_bytes(NFT_OWNERSHIP_TRANSFER_PROGRAM_ONE_WAY_CLAIM_WITH_ROYALTIES) +INTERMEDIATE_LAUNCHER_MOD = Program.from_bytes(NFT_INTERMEDIATE_LAUNCHER) diff --git a/chia/wallet/nft_wallet/nft_wallet.py b/chia/wallet/nft_wallet/nft_wallet.py index 1235cc3327fe..4d53d60422a0 100644 --- a/chia/wallet/nft_wallet/nft_wallet.py +++ b/chia/wallet/nft_wallet/nft_wallet.py @@ -11,8 +11,6 @@ from clvm.casts import int_from_bytes, int_to_bytes from typing_extensions import Unpack -import chia.server.api_protocol -import chia.wallet.singleton from chia.protocols.wallet_protocol import CoinState from chia.server.ws_connection import WSChiaConnection from chia.types.blockchain_format.coin import Coin @@ -35,9 +33,10 @@ from chia.wallet.did_wallet import did_wallet_puzzles from chia.wallet.did_wallet.did_info import DIDInfo from chia.wallet.lineage_proof import LineageProof -from chia.wallet.nft_wallet import nft_puzzles +from chia.wallet.nft_wallet import nft_puzzle_utils from chia.wallet.nft_wallet.nft_info import NFTCoinInfo, NFTWalletInfo -from chia.wallet.nft_wallet.nft_puzzles import NFT_METADATA_UPDATER, create_ownership_layer_puzzle, get_metadata_and_phs +from chia.wallet.nft_wallet.nft_puzzle_utils import create_ownership_layer_puzzle, get_metadata_and_phs +from chia.wallet.nft_wallet.nft_puzzles import NFT_METADATA_UPDATER from chia.wallet.nft_wallet.uncurry_nft import NFTCoinData, UncurriedNFT from chia.wallet.outer_puzzles import AssetType, construct_puzzle, match_puzzle, solve_puzzle from chia.wallet.payment import Payment @@ -47,6 +46,7 @@ calculate_synthetic_secret_key, puzzle_for_pk, ) +from chia.wallet.singleton import SINGLETON_LAUNCHER_PUZZLE, SINGLETON_LAUNCHER_PUZZLE_HASH, create_singleton_puzzle from chia.wallet.trading.offer import OFFER_MOD, OFFER_MOD_HASH, NotarizedPayment, Offer from chia.wallet.transaction_record import TransactionRecord from chia.wallet.uncurried_puzzle import uncurry_puzzle @@ -211,13 +211,13 @@ async def puzzle_solution_received(self, coin: Coin, data: NFTCoinData, peer: WS mint_height: uint32 = uint32(launcher_coin_states[0].spent_height) minter_did = None if uncurried_nft.supports_did: - inner_puzzle = nft_puzzles.recurry_nft_puzzle( + inner_puzzle = nft_puzzle_utils.recurry_nft_puzzle( uncurried_nft, data.parent_coin_spend.solution.to_program(), p2_puzzle ) minter_did = await self.wallet_state_manager.get_minter_did(launcher_coin_states[0].coin, peer) else: inner_puzzle = p2_puzzle - child_puzzle: Program = nft_puzzles.create_full_puzzle( + child_puzzle: Program = nft_puzzle_utils.create_full_puzzle( singleton_id, Program.to(metadata), bytes32(uncurried_nft.metadata_updater_hash.as_atom()), @@ -225,7 +225,7 @@ async def puzzle_solution_received(self, coin: Coin, data: NFTCoinData, peer: WS ) self.log.debug( "Created NFT full puzzle with inner: %s", - nft_puzzles.create_full_puzzle_with_nft_puzzle(singleton_id, uncurried_nft.inner_puzzle), + nft_puzzle_utils.create_full_puzzle_with_nft_puzzle(singleton_id, uncurried_nft.inner_puzzle), ) child_puzzle_hash = child_puzzle.get_tree_hash() for new_coin in compute_additions(data.parent_coin_spend): @@ -353,9 +353,9 @@ async def generate_new_nft( if coins is None: return None origin = coins.copy().pop() - genesis_launcher_puz = nft_puzzles.LAUNCHER_PUZZLE + genesis_launcher_puz = SINGLETON_LAUNCHER_PUZZLE # nft_id == singleton_id == launcher_id == launcher_coin.name() - launcher_coin = Coin(origin.name(), nft_puzzles.LAUNCHER_PUZZLE_HASH, uint64(amount)) + launcher_coin = Coin(origin.name(), SINGLETON_LAUNCHER_PUZZLE_HASH, uint64(amount)) self.log.debug("Generating NFT with launcher coin %s and metadata: %s", launcher_coin, metadata) p2_inner_puzzle = await self.standard_wallet.get_puzzle(new=not action_scope.config.tx_config.reuse_puzhash) @@ -376,7 +376,7 @@ async def generate_new_nft( inner_puzzle = p2_inner_puzzle # singleton eve puzzle - eve_fullpuz = nft_puzzles.create_full_puzzle( + eve_fullpuz = nft_puzzle_utils.create_full_puzzle( launcher_coin.name(), metadata, NFT_METADATA_UPDATER.get_tree_hash(), inner_puzzle ) eve_fullpuz_hash = eve_fullpuz.get_tree_hash() @@ -389,7 +389,7 @@ async def generate_new_nft( # store the launcher transaction in the wallet state await self.standard_wallet.generate_signed_transaction( uint64(amount), - nft_puzzles.LAUNCHER_PUZZLE_HASH, + SINGLETON_LAUNCHER_PUZZLE_HASH, action_scope, fee, coins, @@ -1260,7 +1260,7 @@ async def mint_from_did( for mint_number in range(mint_number_start, mint_number_end): # Create the puzzle, solution and coin spend for the intermediate launcher intermediate_launcher_puz = did_wallet_puzzles.INTERMEDIATE_LAUNCHER_MOD.curry( - chia.wallet.singleton.SINGLETON_LAUNCHER_PUZZLE_HASH, mint_number, mint_total + SINGLETON_LAUNCHER_PUZZLE_HASH, mint_number, mint_total ) intermediate_launcher_ph = intermediate_launcher_puz.get_tree_hash() primaries.append(Payment(intermediate_launcher_ph, uint64(0), [intermediate_launcher_ph])) @@ -1278,9 +1278,7 @@ async def mint_from_did( did_announcements.add(std_hash(intermediate_launcher_coin.name() + intermediate_announcement_message)) # Create the launcher coin, and add its id to a list to be asserted in the DID spend - launcher_coin = Coin( - intermediate_launcher_coin.name(), chia.wallet.singleton.SINGLETON_LAUNCHER_PUZZLE_HASH, amount - ) + launcher_coin = Coin(intermediate_launcher_coin.name(), SINGLETON_LAUNCHER_PUZZLE_HASH, amount) launcher_ids.append(launcher_coin.name()) # Grab the metadata from metadata_list. The index for metadata_list @@ -1295,7 +1293,7 @@ async def mint_from_did( metadata["royalty_pc"], royalty_puzzle_hash=metadata["royalty_ph"], ) - eve_fullpuz = nft_puzzles.create_full_puzzle( + eve_fullpuz = nft_puzzle_utils.create_full_puzzle( launcher_coin.name(), metadata["program"], NFT_METADATA_UPDATER.get_tree_hash(), inner_puzzle ) @@ -1305,9 +1303,7 @@ async def mint_from_did( genesis_launcher_solution = Program.to([eve_fullpuz.get_tree_hash(), amount, []]) - launcher_cs = make_spend( - launcher_coin, chia.wallet.singleton.SINGLETON_LAUNCHER_PUZZLE, genesis_launcher_solution - ) + launcher_cs = make_spend(launcher_coin, SINGLETON_LAUNCHER_PUZZLE, genesis_launcher_solution) launcher_spends.append(launcher_cs) eve_coin = Coin(launcher_coin.name(), eve_fullpuz.get_tree_hash(), uint64(amount)) @@ -1409,7 +1405,7 @@ async def mint_from_did( ), ) did_inner_sol: Program = Program.to([1, did_p2_solution]) - did_full_puzzle: Program = chia.wallet.singleton.create_singleton_puzzle( + did_full_puzzle: Program = create_singleton_puzzle( innerpuz, did_wallet.did_info.origin_coin.name(), ) @@ -1521,8 +1517,8 @@ async def mint_from_xch( # Loop to create each intermediate coin, launcher, eve and (optional) transfer spends for mint_number in range(mint_number_start, mint_number_end): # Create the puzzle, solution and coin spend for the intermediate launcher - intermediate_launcher_puz = nft_puzzles.INTERMEDIATE_LAUNCHER_MOD.curry( - nft_puzzles.LAUNCHER_PUZZLE_HASH, mint_number, mint_total + intermediate_launcher_puz = did_wallet_puzzles.INTERMEDIATE_LAUNCHER_MOD.curry( + SINGLETON_LAUNCHER_PUZZLE_HASH, mint_number, mint_total ) intermediate_launcher_ph = intermediate_launcher_puz.get_tree_hash() primaries.append(Payment(intermediate_launcher_ph, uint64(1), [intermediate_launcher_ph])) @@ -1540,7 +1536,7 @@ async def mint_from_xch( coin_announcements.add(std_hash(intermediate_launcher_coin.name() + intermediate_announcement_message)) # Create the launcher coin, and add its id to a list to be asserted in the XCH spend - launcher_coin = Coin(intermediate_launcher_coin.name(), nft_puzzles.LAUNCHER_PUZZLE_HASH, amount) + launcher_coin = Coin(intermediate_launcher_coin.name(), SINGLETON_LAUNCHER_PUZZLE_HASH, amount) launcher_ids.append(launcher_coin.name()) # Grab the metadata from metadata_list. The index for metadata_list @@ -1556,7 +1552,7 @@ async def mint_from_xch( metadata["royalty_pc"], royalty_puzzle_hash=metadata["royalty_ph"], ) - eve_fullpuz = nft_puzzles.create_full_puzzle( + eve_fullpuz = nft_puzzle_utils.create_full_puzzle( launcher_coin.name(), metadata["program"], NFT_METADATA_UPDATER.get_tree_hash(), inner_puzzle ) @@ -1566,7 +1562,7 @@ async def mint_from_xch( genesis_launcher_solution = Program.to([eve_fullpuz.get_tree_hash(), amount, []]) - launcher_cs = make_spend(launcher_coin, nft_puzzles.LAUNCHER_PUZZLE, genesis_launcher_solution) + launcher_cs = make_spend(launcher_coin, SINGLETON_LAUNCHER_PUZZLE, genesis_launcher_solution) launcher_spends.append(launcher_cs) eve_coin = Coin(launcher_coin.name(), eve_fullpuz.get_tree_hash(), uint64(amount)) diff --git a/chia/wallet/nft_wallet/ownership_outer_puzzle.py b/chia/wallet/nft_wallet/ownership_outer_puzzle.py index 6fe9351c0bac..f41fd8553fd2 100644 --- a/chia/wallet/nft_wallet/ownership_outer_puzzle.py +++ b/chia/wallet/nft_wallet/ownership_outer_puzzle.py @@ -7,17 +7,13 @@ from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 +from chia.wallet.nft_wallet.nft_puzzles import NFT_OWNERSHIP_LAYER from chia.wallet.puzzle_drivers import PuzzleInfo, Solver -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.uncurried_puzzle import UncurriedPuzzle, uncurry_puzzle -OWNERSHIP_LAYER_MOD = load_clvm_maybe_recompile( - "nft_ownership_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" -) - def match_ownership_layer_puzzle(puzzle: UncurriedPuzzle) -> tuple[bool, list[Program]]: - if puzzle.mod == OWNERSHIP_LAYER_MOD: + if puzzle.mod == NFT_OWNERSHIP_LAYER: return True, list(puzzle.args.as_iter()) return False, [] @@ -25,7 +21,7 @@ def match_ownership_layer_puzzle(puzzle: UncurriedPuzzle) -> tuple[bool, list[Pr def puzzle_for_ownership_layer( current_owner: Union[Program, bytes], transfer_program: Program, inner_puzzle: Program ) -> Program: - return OWNERSHIP_LAYER_MOD.curry(OWNERSHIP_LAYER_MOD.get_tree_hash(), current_owner, transfer_program, inner_puzzle) + return NFT_OWNERSHIP_LAYER.curry(NFT_OWNERSHIP_LAYER.get_tree_hash(), current_owner, transfer_program, inner_puzzle) def solution_for_ownership_layer(inner_solution: Program) -> Program: diff --git a/chia/wallet/nft_wallet/transfer_program_puzzle.py b/chia/wallet/nft_wallet/transfer_program_puzzle.py index 7d2cc957d107..feba8b2e8133 100644 --- a/chia/wallet/nft_wallet/transfer_program_puzzle.py +++ b/chia/wallet/nft_wallet/transfer_program_puzzle.py @@ -6,26 +6,21 @@ from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 from chia.util.ints import uint16 +from chia.wallet.nft_wallet.nft_puzzles import NFT_TRANSFER_PROGRAM_DEFAULT from chia.wallet.puzzle_drivers import PuzzleInfo, Solver -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.puzzles.singleton_top_layer_v1_1 import SINGLETON_LAUNCHER_HASH, SINGLETON_MOD_HASH from chia.wallet.uncurried_puzzle import UncurriedPuzzle -TRANSFER_PROGRAM_MOD = load_clvm_maybe_recompile( - "nft_ownership_transfer_program_one_way_claim_with_royalties.clsp", - package_or_requirement="chia.wallet.nft_wallet.puzzles", -) - def match_transfer_program_puzzle(puzzle: UncurriedPuzzle) -> tuple[bool, list[Program]]: - if puzzle.mod == TRANSFER_PROGRAM_MOD: + if puzzle.mod == NFT_TRANSFER_PROGRAM_DEFAULT: return True, list(puzzle.args.as_iter()) return False, [] def puzzle_for_transfer_program(launcher_id: bytes32, royalty_puzzle_hash: bytes32, percentage: uint16) -> Program: singleton_struct = Program.to((SINGLETON_MOD_HASH, (launcher_id, SINGLETON_LAUNCHER_HASH))) - return TRANSFER_PROGRAM_MOD.curry( + return NFT_TRANSFER_PROGRAM_DEFAULT.curry( singleton_struct, royalty_puzzle_hash, percentage, diff --git a/chia/wallet/nft_wallet/uncurry_nft.py b/chia/wallet/nft_wallet/uncurry_nft.py index 33dabe84308f..2f56ea4a3e9c 100644 --- a/chia/wallet/nft_wallet/uncurry_nft.py +++ b/chia/wallet/nft_wallet/uncurry_nft.py @@ -10,14 +10,11 @@ from chia.types.coin_spend import CoinSpend from chia.util.ints import uint16 from chia.util.streamable import Streamable, streamable -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile +from chia.wallet.nft_wallet.nft_puzzles import NFT_OWNERSHIP_LAYER +from chia.wallet.nft_wallet.nft_puzzles import NFT_STATE_LAYER_MOD as NFT_MOD +from chia.wallet.singleton import SINGLETON_TOP_LAYER_MOD log = logging.getLogger(__name__) -SINGLETON_TOP_LAYER_MOD = load_clvm_maybe_recompile("singleton_top_layer_v1_1.clsp") -NFT_MOD = load_clvm_maybe_recompile("nft_state_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles") -NFT_OWNERSHIP_LAYER = load_clvm_maybe_recompile( - "nft_ownership_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles" -) _T_UncurriedNFT = TypeVar("_T_UncurriedNFT", bound="UncurriedNFT") diff --git a/chia/wallet/puzzles/augmented_condition.clsp b/chia/wallet/puzzles/augmented_condition.clsp deleted file mode 100644 index f4aba7d2f082..000000000000 --- a/chia/wallet/puzzles/augmented_condition.clsp +++ /dev/null @@ -1,13 +0,0 @@ -(mod - ( - CONDITION - INNER_PUZZLE - inner_solution - ) - - (c - CONDITION - (a INNER_PUZZLE inner_solution) - ) - -) diff --git a/chia/wallet/puzzles/augmented_condition.clsp.hex b/chia/wallet/puzzles/augmented_condition.clsp.hex deleted file mode 100644 index 18365cc9e468..000000000000 --- a/chia/wallet/puzzles/augmented_condition.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff04ff02ffff02ff05ff0b8080 diff --git a/chia/wallet/puzzles/clawback/drivers.py b/chia/wallet/puzzles/clawback/drivers.py index fcc9875aee72..c2cb94c89e43 100644 --- a/chia/wallet/puzzles/clawback/drivers.py +++ b/chia/wallet/puzzles/clawback/drivers.py @@ -3,6 +3,20 @@ import logging from typing import Any, Optional, Union +from chia_puzzles_py.programs import ( + AUGMENTED_CONDITION as AUGMENTED_CONDITION_BYTES, +) +from chia_puzzles_py.programs import ( + AUGMENTED_CONDITION_HASH as AUGMENTED_CONDITION_HASH_BYTES, +) +from chia_puzzles_py.programs import ( + P2_1_OF_N as P2_1_OF_N_BYTES, +) +from chia_puzzles_py.programs import ( + P2_PUZZLE_HASH, + P2_PUZZLE_HASH_HASH, +) + from chia.consensus.default_constants import DEFAULT_CONSTANTS from chia.types.blockchain_format.coin import Coin from chia.types.blockchain_format.program import Program @@ -14,18 +28,17 @@ from chia.util.ints import uint64 from chia.util.streamable import VersionedBlob from chia.wallet.puzzles.clawback.metadata import ClawbackMetadata -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import MOD from chia.wallet.uncurried_puzzle import UncurriedPuzzle from chia.wallet.util.curry_and_treehash import calculate_hash_of_quoted_mod_hash, curry_and_treehash from chia.wallet.util.merkle_tree import MerkleTree from chia.wallet.util.wallet_types import RemarkDataType -P2_1_OF_N = load_clvm_maybe_recompile("p2_1_of_n.clsp") -P2_CURRIED_PUZZLE_MOD = load_clvm_maybe_recompile("p2_puzzle_hash.clsp") -P2_CURRIED_PUZZLE_MOD_HASH_QUOTED = calculate_hash_of_quoted_mod_hash(P2_CURRIED_PUZZLE_MOD.get_tree_hash()) -AUGMENTED_CONDITION = load_clvm_maybe_recompile("augmented_condition.clsp") -AUGMENTED_CONDITION_HASH = AUGMENTED_CONDITION.get_tree_hash() +P2_1_OF_N = Program.from_bytes(P2_1_OF_N_BYTES) +P2_CURRIED_PUZZLE_MOD = Program.from_bytes(P2_PUZZLE_HASH) +P2_CURRIED_PUZZLE_MOD_HASH_QUOTED = calculate_hash_of_quoted_mod_hash(P2_PUZZLE_HASH_HASH) +AUGMENTED_CONDITION = Program.from_bytes(AUGMENTED_CONDITION_BYTES) +AUGMENTED_CONDITION_HASH = bytes32(AUGMENTED_CONDITION_HASH_BYTES) log = logging.getLogger(__name__) diff --git a/chia/wallet/puzzles/condition_codes.clib b/chia/wallet/puzzles/condition_codes.clib deleted file mode 100644 index a6a5d22b5883..000000000000 --- a/chia/wallet/puzzles/condition_codes.clib +++ /dev/null @@ -1,77 +0,0 @@ -; See chia/types/condition_opcodes.py - -( - - ; Unavailable until after 2.0 hard fork - (defconstant AGG_SIG_PARENT 43) - (defconstant AGG_SIG_PUZZLE 44) - (defconstant AGG_SIG_AMOUNT 45) - (defconstant AGG_SIG_PUZZLE_AMOUNT 46) - (defconstant AGG_SIG_PARENT_AMOUNT 47) - (defconstant AGG_SIG_PARENT_PUZZLE 48) - ; - - (defconstant AGG_SIG_UNSAFE 49) - (defconstant AGG_SIG_ME 50) - - ; the conditions below reserve coin amounts and have to be accounted for in output totals - - (defconstant CREATE_COIN 51) - (defconstant RESERVE_FEE 52) - - ; the conditions below deal with announcements, for inter-coin communication - - ; coin announcements - (defconstant CREATE_COIN_ANNOUNCEMENT 60) - (defconstant ASSERT_COIN_ANNOUNCEMENT 61) - - ; puzzle announcements - (defconstant CREATE_PUZZLE_ANNOUNCEMENT 62) - (defconstant ASSERT_PUZZLE_ANNOUNCEMENT 63) - - ; coin-id - (defconstant ASSERT_CONCURRENT_SPEND 64) - ; puzzle-hash - (defconstant ASSERT_CONCURRENT_PUZZLE 65) - - ; mask message ... - (defconstant SEND_MESSAGE 66) - (defconstant RECEIVE_MESSAGE 67) - - ; the conditions below let coins inquire about themselves - - (defconstant ASSERT_MY_COIN_ID 70) - (defconstant ASSERT_MY_PARENT_ID 71) - (defconstant ASSERT_MY_PUZZLEHASH 72) - (defconstant ASSERT_MY_AMOUNT 73) - (defconstant ASSERT_MY_BIRTH_SECONDS 74) - (defconstant ASSERT_MY_BIRTH_HEIGHT 75) - (defconstant ASSERT_EPHEMERAL 76) - - ; the conditions below ensure that we're "far enough" in the future - - ; wall-clock time - (defconstant ASSERT_SECONDS_RELATIVE 80) - (defconstant ASSERT_SECONDS_ABSOLUTE 81) - - ; block index - (defconstant ASSERT_HEIGHT_RELATIVE 82) - (defconstant ASSERT_HEIGHT_ABSOLUTE 83) - - ; the conditions below ensure that we're "not too far" in the future - - ; wall-clock time - (defconstant ASSERT_BEFORE_SECONDS_RELATIVE 84) - (defconstant ASSERT_BEFORE_SECONDS_ABSOLUTE 85) - - ; block index - (defconstant ASSERT_BEFORE_HEIGHT_RELATIVE 86) - (defconstant ASSERT_BEFORE_HEIGHT_ABSOLUTE 87) - - ; A condition that is always true and always ignore all arguments - (defconstant REMARK 1) - - ; A condition whose first argument specifies its cost, but is unkown otherwise - ; It's a place-holder for soft-forking in new conditions - (defconstant SOFTFORK 90) -) diff --git a/chia/wallet/puzzles/curry-and-treehash.clib b/chia/wallet/puzzles/curry-and-treehash.clib deleted file mode 100644 index 0b7632aad368..000000000000 --- a/chia/wallet/puzzles/curry-and-treehash.clib +++ /dev/null @@ -1,102 +0,0 @@ -;; -;; THIS FILE IS DEPRECATED and is only for legacy contracts. -;; Please use `curry.clib` going forward. It has a less stupid API. -;; - -( - ;; The code below is used to calculate of the tree hash of a curried function - ;; without actually doing the curry, and using other optimization tricks - ;; like unrolling `sha256tree`. - - (defconstant ONE 1) - (defconstant TWO 2) - (defconstant A_KW #a) - (defconstant Q_KW #q) - (defconstant C_KW #c) - - ;; Given the tree hash `environment-hash` of an environment tree E - ;; and the tree hash `parameter-hash` of a constant parameter P - ;; return the tree hash of the tree corresponding to - ;; `(c (q . P) E)` - ;; This is the new environment tree with the addition parameter P curried in. - ;; - ;; Note that `(c (q . P) E)` = `(c . ((q . P) . (E . 0)))` - - (defun-inline update-hash-for-parameter-hash (parameter-hash environment-hash) - (sha256 TWO (sha256 ONE C_KW) - (sha256 TWO (sha256 TWO (sha256 ONE Q_KW) parameter-hash) - (sha256 TWO environment-hash (sha256 ONE 0)))) - ) - - ;; This function recursively calls `update-hash-for-parameter-hash`, updating `environment-hash` - ;; along the way. - - (defun build-curry-list (reversed-curry-parameter-hashes environment-hash) - (if reversed-curry-parameter-hashes - (build-curry-list (r reversed-curry-parameter-hashes) - (update-hash-for-parameter-hash (f reversed-curry-parameter-hashes) environment-hash)) - environment-hash - ) - ) - - ;; Given the tree hash `environment-hash` of an environment tree E - ;; and the tree hash `function-hash` of a function tree F - ;; return the tree hash of the tree corresponding to - ;; `(a (q . F) E)` - ;; This is the hash of a new function that adopts the new environment E. - ;; This is used to build of the tree hash of a curried function. - ;; - ;; Note that `(a (q . F) E)` = `(a . ((q . F) . (E . 0)))` - - (defun-inline tree-hash-of-apply (function-hash environment-hash) - (sha256 TWO (sha256 ONE A_KW) - (sha256 TWO (sha256 TWO (sha256 ONE Q_KW) function-hash) - (sha256 TWO environment-hash (sha256 ONE 0)))) - ) - - ;; DO NOT USE THIS FUNCTION GOING FORWARD. Having to pass the arguments in reverse order is stupid. - ;; When I (RK) wrote this, I thought it was necessary, but of course, I was just being dumb - ;; and it is not necessary. It's very confusing. - ;; - ;; function-hash: - ;; the hash of a puzzle function, ie. a `mod` - ;; - ;; reversed-curry-parameter-hashes: - ;; a list of pre-hashed trees representing parameters to be curried into the puzzle. - ;; Note that this must be applied in REVERSED order. This may seem strange, but it greatly simplifies - ;; the underlying code, since we calculate the tree hash from the bottom nodes up, and the last - ;; parameters curried must have their hashes calculated first. - ;; - ;; we return the hash of the curried expression - ;; (a (q . function-hash) (c (cp1 (c cp2 (c ... 1)...)))) - ;; - ;; Note that from a user's perspective the hashes passed in here aren't simply - ;; the hashes of the desired parameters, but their treehash representation since - ;; that's the form we're assuming they take in the actual curried program. - - ;; DO NOT USE - (defun puzzle-hash-of-curried-function (function-hash . reversed-curry-parameter-hashes) - (tree-hash-of-apply function-hash - (build-curry-list reversed-curry-parameter-hashes (sha256 ONE ONE))) - ) - - (defconstant b32 32) - - (defun-inline size_b32 (var) - (= (strlen var) b32) - ) - - (defun calculate_coin_id (parent puzzlehash amount) - (if (all (size_b32 parent) (size_b32 puzzlehash) (> amount -1)) - (sha256 parent puzzlehash amount) - (x) - ) - ) - - ; takes a lisp tree and returns the hash of it - (defun sha256tree (TREE) - (if (l TREE) - (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE))) - (sha256 1 TREE))) - -) diff --git a/chia/wallet/puzzles/curry.clib b/chia/wallet/puzzles/curry.clib deleted file mode 100644 index d99498726247..000000000000 --- a/chia/wallet/puzzles/curry.clib +++ /dev/null @@ -1,135 +0,0 @@ -( - ;; The code below is used to calculate of the tree hash of a curried function - ;; without actually doing the curry, and using other optimization tricks - ;; like unrolling `sha256tree`. - - (defconstant TWO 2) - (defconstant constant_tree ( - (0x4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a . ; = `(sha256 1)` - 0x9dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2) . ; = `(sha256 1 1)` = `(sha256 1 #q)` - (0x02a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222 . ; = `(concat 2 (sha256 1 #a))` - 0x02a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5) ; = `(concat 2 (sha256 1 #c))` - ) - ) - - ; I looked into calculating the values of `constant_tree` because it's pretty easy to code-golf - ; out an implementation that produces the values cheaper than just inlining them. The problem is, - ; when do we calculate them? If there were a way to calculate it "before main" and include it in - ; the globally-accessible constant table, we could do that. But we can't which means to be optimal, - ; client code should call the "build table" code once, then pass it around to anyone that wants to - ; call `curry` or `curry2`. This is pretty intrusive, so for now we'll just use the existing - ; global constant infrastructure, and include it as a fixed table so the tree of four values will - ; appear in all code that includes this file, and it will compress better in generators. - - (defun-inline sha256_one _noargs (f (f constant_tree))) - (defun-inline sha256_one_one _noargs (r (f constant_tree))) - (defun-inline two_sha256_one_a_kw _noargs (f (r constant_tree))) - (defun-inline two_sha256_one_c_kw _noargs (r (r constant_tree))) - - ;; this returns the sha256 tree hash of expression F = `((q . a1) a2)` - (defun hash_expression_F (a1 a2) - (sha256 TWO (sha256 TWO (sha256_one_one) a1) - (sha256 TWO a2 (sha256_one))) - ) - - ;; Given the tree hash `environment_hash` of an environment tree E - ;; and the tree hash `parameter_hash` of a constant parameter P - ;; return the tree hash of the tree corresponding to - ;; `(c (q . P) E)` - ;; This is the new environment tree with the addition parameter P curried in. - ;; - ;; Note that `(c (q . P) E)` = `(c . ((q . P) . (E . 0)))` - - (defun-inline update_hash_for_parameter_hash (parameter_hash environment_hash) - (sha256 (two_sha256_one_c_kw) (hash_expression_F parameter_hash environment_hash)) - ) - - ;; Given the tree hash `environment_hash` of an environment tree E - ;; and the tree hash `mod_hash` of a mod M - ;; return the tree hash of the tree corresponding to - ;; `(a (q . M) E)` - ;; This is the hash of a new function that adopts the new environment E. - ;; This is used to build of the tree hash of a curried function. - ;; - ;; Note that `(a (q . M) E)` = `(a . ((q . M) . (E . 0)))` - - (defun-inline tree_hash_of_apply (mod_hash environment_hash) - (sha256 (two_sha256_one_a_kw) (hash_expression_F mod_hash environment_hash)) - ) - - ;; This function recursively calls `update_hash_for_parameter_hash` - - (defun calculate_hash_of_curried_parameters (curry_parameter_hashes) - (if curry_parameter_hashes - (update_hash_for_parameter_hash (f curry_parameter_hashes) (calculate_hash_of_curried_parameters (r curry_parameter_hashes))) - (sha256_one_one) - ) - ) - - ;; mod_hash: - ;; the hash of a puzzle function, ie. a `mod` - ;; - ;; curry_parameter_hashes: - ;; a list of pre_hashed trees representing parameters to be curried into the puzzle. - ;; - ;; we return the hash of the curried expression - ;; (a (q . mod_hash) (c (cp1 (c cp2 (c ... 1)...)))) - ;; - ;; Note that from a user's perspective the hashes passed in here aren't simply - ;; the hashes of the desired parameters, but their treehash representation since - ;; that's the form we're assuming they take in the acutal curried program. - - ;; inline functions that take varargs don't seem to work, so we can't inline `curry` - - (defun curry_hashes (mod_hash . curry_parameter_hashes) - (tree_hash_of_apply mod_hash - (calculate_hash_of_curried_parameters curry_parameter_hashes)) - ) - - - ;; This is the macro version that inlines everything and expects varargs parameters. - ;; It may be more efficient in some cases. - - (defmacro curry_hashes_inline (mod_hash . curry_parameter_hashes) - (qq - (sha256 - ; apply - (two_sha256_one_a_kw) - (sha256 TWO - ; func - (sha256 TWO - (sha256_one_one) - (unquote mod_hash) - ) - (sha256 TWO - ; args - (unquote (c build_pre_hashed_environment curry_parameter_hashes)) - (sha256_one) - ) - ) - ) - ) - ) - - - ;; helper macro - - (defmacro build_pre_hashed_environment curry_parameter_hashes - (qq - (sha256 - (two_sha256_one_c_kw) - (sha256 TWO - (sha256 TWO - (sha256_one_one) - (unquote (f curry_parameter_hashes)) - ) - (sha256 TWO - (unquote (if (r curry_parameter_hashes) (c build_pre_hashed_environment (r curry_parameter_hashes)) (q . (sha256_one_one)))) - (sha256_one) - ) - ) - ) - ) - ) - -) diff --git a/chia/wallet/puzzles/curry_by_index.clib b/chia/wallet/puzzles/curry_by_index.clib deleted file mode 100644 index 299f2fd6975b..000000000000 --- a/chia/wallet/puzzles/curry_by_index.clib +++ /dev/null @@ -1,16 +0,0 @@ -( - (defun recurry_by_index_ordered ( - index_value_pairs_list ; MUST BE ORDERED - current_position ; must be 0 on initial call - CURRENT_PARAMS ; current list of curry params - ) - (if index_value_pairs_list - (if (= (f (f index_value_pairs_list)) current_position) - (c (r (f index_value_pairs_list)) (recurry_by_index_ordered (r index_value_pairs_list) (+ current_position 1) (r CURRENT_PARAMS))) - (c (f CURRENT_PARAMS) (recurry_by_index_ordered index_value_pairs_list (+ current_position 1) (r CURRENT_PARAMS))) - ) - () - ) - ) - -) diff --git a/chia/wallet/puzzles/dao_cat_eve.clsp b/chia/wallet/puzzles/dao_cat_eve.clsp deleted file mode 100644 index c19b8c16b794..000000000000 --- a/chia/wallet/puzzles/dao_cat_eve.clsp +++ /dev/null @@ -1,17 +0,0 @@ -; This file is what the first form the CAT takes, and then it gets immediately eve spent out of here. -; This allows the coin to move into its real state already having been eve spent and validated to not be a fake CAT. -; The trick is that we won't know what the real state puzzlehash reveal is, but we will know what this is. -; Mint into this, eve spend out of this -(mod ( - NEW_PUZZLE_HASH ; this is the CAT inner_puzzle - my_amount - tail_reveal - tail_solution - ) - (include condition_codes.clib) - (list - (list CREATE_COIN NEW_PUZZLE_HASH my_amount (list NEW_PUZZLE_HASH)) - (list ASSERT_MY_AMOUNT my_amount) - (list CREATE_COIN 0 -113 tail_reveal tail_solution) ; this is secure because anything but the real values won't work - ) -) diff --git a/chia/wallet/puzzles/dao_cat_eve.clsp.hex b/chia/wallet/puzzles/dao_cat_eve.clsp.hex deleted file mode 100644 index 23f72b9be40f..000000000000 --- a/chia/wallet/puzzles/dao_cat_eve.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff06ffff04ff05ffff04ff0bffff04ffff04ff05ff8080ff8080808080ffff04ffff04ff04ffff04ff0bff808080ffff04ffff04ff06ffff04ff80ffff04ffff01818fffff04ff17ffff04ff2fff808080808080ff80808080ffff04ffff01ff4933ff018080 diff --git a/chia/wallet/puzzles/dao_cat_launcher.clsp b/chia/wallet/puzzles/dao_cat_launcher.clsp deleted file mode 100644 index 61c8bdfe68a3..000000000000 --- a/chia/wallet/puzzles/dao_cat_launcher.clsp +++ /dev/null @@ -1,36 +0,0 @@ -(mod ( - TREASURY_SINGLETON_STRUCT - treasury_inner_puz_hash - parent_parent - new_puzzle_hash ; the full CAT puzzle - amount - ) - (include condition_codes.clib) - (include curry-and-treehash.clib) - - (defun calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree PROPOSAL_SINGLETON_STRUCT) - ) - ) - - (defun create_parent_conditions (parent_id new_puzzle_hash amount) - (list - (list ASSERT_COIN_ANNOUNCEMENT (sha256 parent_id (sha256tree (list 'm' new_puzzle_hash)))) - (list ASSERT_MY_PARENT_ID parent_id) - ) - ) - - (c - (list CREATE_COIN new_puzzle_hash amount (list new_puzzle_hash)) - (c - (list ASSERT_MY_AMOUNT amount) - (create_parent_conditions - (sha256 parent_parent (calculate_singleton_puzzle_hash TREASURY_SINGLETON_STRUCT treasury_inner_puz_hash) ONE) - new_puzzle_hash - amount - ) - ) - ) -) diff --git a/chia/wallet/puzzles/dao_cat_launcher.clsp.hex b/chia/wallet/puzzles/dao_cat_launcher.clsp.hex deleted file mode 100644 index 8e2dcfd95e16..000000000000 --- a/chia/wallet/puzzles/dao_cat_launcher.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff34ffff04ff2fffff04ff5fffff04ffff04ff2fff8080ff8080808080ffff04ffff04ff28ffff04ff5fff808080ffff02ff36ffff04ff02ffff04ffff0bff17ffff02ff26ffff04ff02ffff04ff05ffff04ff0bff8080808080ff3c80ffff04ff2fffff04ff5fff8080808080808080ffff04ffff01ffffff3dff4947ffff0233ff0401ffff01ff02ff02ffff03ff05ffff01ff02ff3affff04ff02ffff04ff0dffff04ffff0bff2affff0bff3cff2c80ffff0bff2affff0bff2affff0bff3cff1280ff0980ffff0bff2aff0bffff0bff3cff8080808080ff8080808080ffff010b80ff0180ffffff02ff2effff04ff02ffff04ff09ffff04ff0bffff04ffff02ff3effff04ff02ffff04ff05ff80808080ff808080808080ff04ffff04ff10ffff04ffff0bff05ffff02ff3effff04ff02ffff04ffff04ffff016dffff04ff0bff808080ff8080808080ff808080ffff04ffff04ff38ffff04ff05ff808080ff808080ffff0bff2affff0bff3cff2480ffff0bff2affff0bff2affff0bff3cff1280ff0580ffff0bff2affff02ff3affff04ff02ffff04ff07ffff04ffff0bff3cff3c80ff8080808080ffff0bff3cff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/dao_finished_state.clsp b/chia/wallet/puzzles/dao_finished_state.clsp deleted file mode 100644 index d0d9673004c0..000000000000 --- a/chia/wallet/puzzles/dao_finished_state.clsp +++ /dev/null @@ -1,35 +0,0 @@ -; This code is the end state of a proposal or a dividend. -; It is an oracle which simply recreates itself and emits an announcement that it has concluded operation - -(mod (SINGLETON_STRUCT DAO_FINISHED_STATE_MOD_HASH my_amount) - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include *standard-cl-21*) - - (defun wrap_in_singleton (SINGLETON_STRUCT my_inner_puzhash) - (puzzle-hash-of-curried-function (f SINGLETON_STRUCT) - my_inner_puzhash - (sha256tree SINGLETON_STRUCT) - ) - ) - - (defun recreate_self (SINGLETON_STRUCT DAO_FINISHED_STATE_MOD_HASH) - (puzzle-hash-of-curried-function DAO_FINISHED_STATE_MOD_HASH - (sha256 ONE DAO_FINISHED_STATE_MOD_HASH) - (sha256tree SINGLETON_STRUCT) - ) - ) - - - (let - ( - (my_inner_puzhash (recreate_self SINGLETON_STRUCT DAO_FINISHED_STATE_MOD_HASH)) - ) - (list - (list ASSERT_MY_PUZZLEHASH (wrap_in_singleton SINGLETON_STRUCT my_inner_puzhash)) - (list ASSERT_MY_AMOUNT my_amount) - (list CREATE_COIN my_inner_puzhash my_amount) - (list CREATE_PUZZLE_ANNOUNCEMENT 0) - ) - ) -) diff --git a/chia/wallet/puzzles/dao_finished_state.clsp.hex b/chia/wallet/puzzles/dao_finished_state.clsp.hex deleted file mode 100644 index e9bf9163b7dd..000000000000 --- a/chia/wallet/puzzles/dao_finished_state.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ffff0148ffff04ffff02ff16ffff04ff02ffff04ffff05ffff06ff018080ffff04ffff02ff1effff04ff02ffff04ff05ffff04ff0bff8080808080ff8080808080ffff01808080ffff04ffff04ffff0149ffff04ffff05ffff06ffff06ffff06ff0180808080ffff01808080ffff04ffff04ffff0133ffff04ffff02ff1effff04ff02ffff04ff05ffff04ff0bff8080808080ffff04ffff05ffff06ffff06ffff06ff0180808080ffff0180808080ffff04ffff04ffff013effff04ffff0180ffff01808080ffff018080808080ffff04ffff01ffffff02ffff03ff05ffff01ff02ffff01ff02ff08ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff08ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff0affff04ff02ffff04ffff05ff0580ff80808080ffff02ff0affff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ff0cffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff0affff04ff02ffff04ff05ff80808080ff808080808080ff02ff0cffff04ff02ffff04ff0bffff04ffff0bffff0101ff0b80ffff04ffff02ff0affff04ff02ffff04ff05ff80808080ff808080808080ff018080 diff --git a/chia/wallet/puzzles/dao_finished_state.clsp.hex.sha256tree b/chia/wallet/puzzles/dao_finished_state.clsp.hex.sha256tree deleted file mode 100644 index ecf06a70d925..000000000000 --- a/chia/wallet/puzzles/dao_finished_state.clsp.hex.sha256tree +++ /dev/null @@ -1 +0,0 @@ -7f3cc356732907933a8f9b1ccf16f71735d07340eb38c847aa402e97d75eb40b diff --git a/chia/wallet/puzzles/dao_lockup.clsp b/chia/wallet/puzzles/dao_lockup.clsp deleted file mode 100644 index 5ffb8320f6da..000000000000 --- a/chia/wallet/puzzles/dao_lockup.clsp +++ /dev/null @@ -1,288 +0,0 @@ -; This code is the "voting mode" for a DAO CAT. -; The coin can be spent from this state to vote on a proposal or claim a dividend. -; It locks the CAT in while it has active votes/dividends going on. -; Once a vote or dividend closes, then the coin can spend itself to remove that coin from the "active list" -; If the "active list" is empty the coin can leave the voting mode - -(mod ( - ; this is the first curry - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_PUZHASH - DAO_FINISHED_STATE_MOD_HASH - CAT_MOD_HASH - CAT_TAIL_HASH - ; this is the second curry - SELF_HASH ; this is the self_hash Optimization - ACTIVE_VOTES ; "active votes" list - INNERPUZ - ; this is the solution - my_id ; if my_id is 0 we do the return to return_address (exit voting mode) spend case - inner_solution - my_amount - new_proposal_vote_id_or_removal_id ; removal_id is a list of removal_ids - proposal_innerpuzhash ; list of singleton innerpuzhashes which should match the order of the new_proposal_vote_id list - vote_info - vote_amount - my_inner_puzhash - new_innerpuzhash ; only include this if we're changing owners - secured because coin is still made from inner_puz - ) - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include *standard-cl-21*) - - (defun calculate_finished_state (singleton_struct dao_finished_state) - (puzzle-hash-of-curried-function dao_finished_state - (sha256 ONE dao_finished_state) - (sha256tree singleton_struct) - ) - ) - - ; take two lists and merge them into one - (defun merge_list (list_a list_b) - (if list_a - (c (f list_a) (merge_list (r list_a) list_b)) - list_b - ) - ) - - (defun wrap_in_cat_layer (CAT_MOD_HASH CAT_TAIL_HASH INNERPUZHASH) - (puzzle-hash-of-curried-function CAT_MOD_HASH - INNERPUZHASH - (sha256 ONE CAT_TAIL_HASH) - (sha256 ONE CAT_MOD_HASH) - ) - ) - - ; loop through conditions and check that they aren't trying to create anything they shouldn't - (defun check_conditions (conditions vote_added_puzhash my_amount message vote_amount my_inner_puzhash seen_vote seen_change) - (if conditions - (if (= (f (f conditions)) CREATE_COIN) ; this guarantees that the new coin is obeying the rules - other coins are banned to avoid re-voting - (if (= (f (r (f conditions))) vote_added_puzhash) - (if seen_vote ; assert we haven't already made a coin with the new vote included - (x) - (if (= (f (r (r (f conditions)))) my_amount) ; we vote with all our value - (if seen_change ; assert that we haven't already recreated ourself in some fashion - (x) - (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash 1 1)) - ) - (if (= (f (r (r (f conditions)))) vote_amount) ; we vote with part of our power - (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash 1 seen_change)) - (x) - ) - ) - ) - (if (all - (= (f (r (f conditions))) my_inner_puzhash) - (not seen_change) - (= (f (r (r (f conditions)))) (- my_amount vote_amount)) - ) ; we recreate ourselves with unused voting power - (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash seen_vote 1)) - (x) - ) - ) - (if (= (f (f conditions)) CREATE_PUZZLE_ANNOUNCEMENT) ; this secures the values used to generate message - other messages are banned in case of LIES - (if (= (f (r (f conditions))) message) - (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash seen_vote seen_change)) - (x) - ) - (c (f conditions) (check_conditions (r conditions) vote_added_puzhash my_amount message vote_amount my_inner_puzhash seen_vote seen_change)) - ) - ) - (if (all seen_vote seen_change) ; check all value is accounted for - () - (x) - ) - ) - ) - - ; go through our list of active votes and check that we aren't revoting - (defun check_not_previously_voted ( - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_PUZHASH - INNERPUZ - my_id - new_vote_id - active_votes - proposal_innerpuzhash - ) - (if active_votes - (if (= new_vote_id (f active_votes)) ; check new vote id is not equal to an existent vote id - (x) - (check_not_previously_voted - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_PUZHASH - INNERPUZ - my_id - new_vote_id - (r active_votes) - proposal_innerpuzhash - ) - ) - (list ASSERT_PUZZLE_ANNOUNCEMENT - (sha256 - (calculate_singleton_puzzle_hash - (c SINGLETON_MOD_HASH (c new_vote_id SINGLETON_LAUNCHER_PUZHASH)) - proposal_innerpuzhash - ) - my_id - ) - ) - ) - ) - - - (defun calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree PROPOSAL_SINGLETON_STRUCT) - ) - ) - - (defun calculate_lockup_puzzlehash ( - SELF_HASH - active_votes - innerpuzhash - ) - (puzzle-hash-of-curried-function SELF_HASH - innerpuzhash - (sha256tree active_votes) - (sha256 ONE SELF_HASH) - ) - ) - - (defun for_every_removal_id ( - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_PUZHASH - SELF_HASH - DAO_FINISHED_STATE_MOD_HASH - CAT_MOD_HASH - CAT_TAIL_HASH - ACTIVE_VOTES - INNERPUZ - removal_ids - my_amount - unused_votes - ) - (if removal_ids - (c - (list - ASSERT_PUZZLE_ANNOUNCEMENT ; check proposal is actually finished - (sha256 - (calculate_singleton_puzzle_hash - (c SINGLETON_MOD_HASH (c (f removal_ids) SINGLETON_LAUNCHER_PUZHASH)) - (calculate_finished_state - (c SINGLETON_MOD_HASH (c (f removal_ids) SINGLETON_LAUNCHER_PUZHASH)) - DAO_FINISHED_STATE_MOD_HASH - ) - ) - 0 - ) - ) - (for_every_removal_id - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_PUZHASH - SELF_HASH - DAO_FINISHED_STATE_MOD_HASH - CAT_MOD_HASH - CAT_TAIL_HASH - ACTIVE_VOTES - INNERPUZ - (r removal_ids) - my_amount - (c (f removal_ids) unused_votes) - ) - ) - (list - (list ASSERT_MY_AMOUNT my_amount) ; assert that we aren't lying about our amount to free up money and re-vote - (list - CREATE_COIN ; recreate self with the finished proposal ID removed - (calculate_lockup_puzzlehash - SELF_HASH - (remove_list_one_entries_from_list_two unused_votes ACTIVE_VOTES) - (sha256tree INNERPUZ) - ) - my_amount - ) - ) - ) - ) - - (defun remove_list_one_entries_from_list_two (list_one list_two) - (if list_one - (remove_item_from_list (f list_one) (remove_list_one_entries_from_list_two (r list_one) list_two)) - list_two - ) - ) - - (defun remove_item_from_list (item list_one) - (if list_one - (if (= (f list_one) item) - (r list_one) ; assuming there are no duplicates - (c (f list_one) (remove_item_from_list item (r list_one))) - ) - () ; item was never in list_one, return list_two entirely - ) - ) - - - ; main - (if my_id - (c (list ASSERT_MY_PUZZLEHASH (wrap_in_cat_layer CAT_MOD_HASH CAT_TAIL_HASH my_inner_puzhash)) - (c - (list ASSERT_MY_AMOUNT my_amount) - (c - (list ASSERT_MY_COIN_ID my_id) - (c - (if new_proposal_vote_id_or_removal_id - (check_not_previously_voted ; this returns a single condition asserting announcement from vote singleton - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_PUZHASH - INNERPUZ - my_id - new_proposal_vote_id_or_removal_id - ACTIVE_VOTES - proposal_innerpuzhash - ) - (list REMARK) - ) - - ; loop over conditions and check that we aren't trying to leave voting state - (check_conditions - (a INNERPUZ inner_solution) - (calculate_lockup_puzzlehash ; compare created coin to our own calculation on what the next puzzle should be - SELF_HASH - (if new_proposal_vote_id_or_removal_id (c new_proposal_vote_id_or_removal_id ACTIVE_VOTES) ACTIVE_VOTES) - (if new_innerpuzhash new_innerpuzhash (sha256tree INNERPUZ)) - ) - my_amount - ; TODO: add namespace to this announcement to allow announcements from the innerpuz - (sha256tree (list new_proposal_vote_id_or_removal_id vote_amount vote_info my_id)) - vote_amount - my_inner_puzhash - 0 - 0 - ) - ) - ) - ) - ) - - ; return to return_address or remove something from active list - check if our locked list is empty - (if ACTIVE_VOTES - (for_every_removal_id ; locked list is not empty, so we must be trying to remove something from it - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_PUZHASH - SELF_HASH - DAO_FINISHED_STATE_MOD_HASH - CAT_MOD_HASH - CAT_TAIL_HASH - ACTIVE_VOTES - INNERPUZ - new_proposal_vote_id_or_removal_id - my_amount - () - ) - (a INNERPUZ inner_solution) - ) - ) -) diff --git a/chia/wallet/puzzles/dao_lockup.clsp.hex b/chia/wallet/puzzles/dao_lockup.clsp.hex deleted file mode 100644 index 793e3d66108d..000000000000 --- a/chia/wallet/puzzles/dao_lockup.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff8205ffffff01ff02ffff01ff04ffff04ffff0148ffff04ffff02ff2cffff04ff02ffff04ff2fffff04ff5fffff04ff8302ffffff808080808080ffff01808080ffff04ffff04ffff0149ffff04ff8217ffffff01808080ffff04ffff04ffff0146ffff04ff8205ffffff01808080ffff04ffff02ffff03ff822fffffff01ff02ffff01ff02ff12ffff04ff02ffff04ff05ffff04ff0bffff04ff8202ffffff04ff8205ffffff04ff822fffffff04ff82017fffff04ff825fffff80808080808080808080ff0180ffff01ff02ffff01ff04ffff0101ffff018080ff018080ff0180ffff02ff3cffff04ff02ffff04ffff02ff8202ffff820bff80ffff04ffff02ff3affff04ff02ffff04ff8200bfffff04ffff02ffff03ff822fffffff01ff02ffff01ff04ff822fffff82017f80ff0180ffff01ff02ffff0182017fff018080ff0180ffff04ffff02ffff03ff8305ffffffff01ff02ffff018305ffffff0180ffff01ff02ffff01ff02ff38ffff04ff02ffff04ff8202ffff80808080ff018080ff0180ff808080808080ffff04ff8217ffffff04ffff02ff38ffff04ff02ffff04ffff04ff822fffffff04ff83017fffffff04ff8300bfffffff04ff8205ffffff018080808080ff80808080ffff04ff83017fffffff04ff8302ffffffff04ffff0180ffff04ffff0180ff808080808080808080808080808080ff0180ffff01ff02ffff01ff02ffff03ff82017fffff01ff02ffff01ff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff8200bfffff04ff17ffff04ff2fffff04ff5fffff04ff82017fffff04ff8202ffffff04ff822fffffff04ff8217ffffff04ffff0180ff8080808080808080808080808080ff0180ffff01ff02ffff01ff02ff8202ffff820bff80ff018080ff0180ff018080ff0180ffff04ffff01ffffffff02ffff03ff05ffff01ff02ffff01ff02ff10ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ffff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff10ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff38ffff04ff02ffff04ffff05ff0580ff80808080ffff02ff38ffff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ff28ffff04ff02ffff04ff0bffff04ffff0bffff0101ff0b80ffff04ffff02ff38ffff04ff02ffff04ff05ff80808080ff808080808080ffff02ff28ffff04ff02ffff04ff05ffff04ff17ffff04ffff0bffff0101ff0b80ffff04ffff0bffff0101ff0580ff80808080808080ff02ffff03ff05ffff01ff02ffff01ff02ffff03ffff09ffff05ffff05ff058080ffff013380ffff01ff02ffff01ff02ffff03ffff09ffff05ffff06ffff05ff05808080ff0b80ffff01ff02ffff01ff02ffff03ff82017fffff01ff02ffff01ff0880ff0180ffff01ff02ffff01ff02ffff03ffff09ffff05ffff06ffff06ffff05ff0580808080ff1780ffff01ff02ffff01ff02ffff03ff8202ffffff01ff02ffff01ff0880ff0180ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ffff0101ffff04ffff0101ff808080808080808080808080ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ffff09ffff05ffff06ffff06ffff05ff0580808080ff5f80ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ffff0101ffff04ff8202ffff808080808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff018080ff0180ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ffff22ffff09ffff05ffff06ffff05ff05808080ff8200bf80ffff20ff8202ff80ffff09ffff05ffff06ffff06ffff05ff0580808080ffff11ff17ff5f808080ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ffff0101ff808080808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ffff09ffff05ffff05ff058080ffff013e80ffff01ff02ffff01ff02ffff03ffff09ffff05ffff06ffff05ff05808080ff2f80ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ff8202ffff808080808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff04ffff05ff0580ffff02ff3cffff04ff02ffff04ffff06ff0580ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ff8202ffff808080808080808080808080ff018080ff0180ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ffff22ff82017fff8202ff80ffff01ff02ffff01ff0180ff0180ffff01ff02ffff01ff0880ff018080ff0180ff018080ff0180ffffff02ffff03ff8200bfffff01ff02ffff01ff02ffff03ffff09ff5fffff05ff8200bf8080ffff01ff02ffff01ff0880ff0180ffff01ff02ffff01ff02ff12ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ffff06ff8200bf80ffff04ff82017fff80808080808080808080ff018080ff0180ff0180ffff01ff02ffff01ff04ffff013fffff04ffff0bffff02ff2affff04ff02ffff04ffff04ff05ffff04ff5fff0b8080ffff04ff82017fff8080808080ff2f80ffff01808080ff018080ff0180ffff02ff28ffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff38ffff04ff02ffff04ff05ff80808080ff808080808080ff02ff28ffff04ff02ffff04ff05ffff04ff17ffff04ffff02ff38ffff04ff02ffff04ff0bff80808080ffff04ffff0bffff0101ff0580ff80808080808080ffff02ffff03ff8205ffffff01ff02ffff01ff04ffff04ffff013fffff04ffff0bffff02ff2affff04ff02ffff04ffff04ff05ffff04ffff05ff8205ff80ff0b8080ffff04ffff02ff14ffff04ff02ffff04ffff04ff05ffff04ffff05ff8205ff80ff0b8080ffff04ff2fff8080808080ff8080808080ffff018080ffff01808080ffff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ff8202ffffff04ffff06ff8205ff80ffff04ff820bffffff04ffff04ffff05ff8205ff80ff8217ff80ff808080808080808080808080808080ff0180ffff01ff02ffff01ff04ffff04ffff0149ffff04ff820bffffff01808080ffff04ffff04ffff0133ffff04ffff02ff3affff04ff02ffff04ff17ffff04ffff02ff2effff04ff02ffff04ff8217ffffff04ff82017fff8080808080ffff04ffff02ff38ffff04ff02ffff04ff8202ffff80808080ff808080808080ffff04ff820bffffff0180808080ffff01808080ff018080ff0180ffff02ffff03ff05ffff01ff02ffff01ff02ff3effff04ff02ffff04ffff05ff0580ffff04ffff02ff2effff04ff02ffff04ffff06ff0580ffff04ff0bff8080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff02ffff03ff0bffff01ff02ffff01ff02ffff03ffff09ffff05ff0b80ff0580ffff01ff02ffff01ff06ff0b80ff0180ffff01ff02ffff01ff04ffff05ff0b80ffff02ff3effff04ff02ffff04ff05ffff04ffff06ff0b80ff808080808080ff018080ff0180ff0180ffff01ff02ffff01ff0180ff018080ff0180ff018080 diff --git a/chia/wallet/puzzles/dao_lockup.clsp.hex.sha256tree b/chia/wallet/puzzles/dao_lockup.clsp.hex.sha256tree deleted file mode 100644 index 3932de2d5436..000000000000 --- a/chia/wallet/puzzles/dao_lockup.clsp.hex.sha256tree +++ /dev/null @@ -1 +0,0 @@ -9fa63e652e131f89a9f8bb6f7abb5ffc6ac485a78dcfb8710cd9df5c368774d9 diff --git a/chia/wallet/puzzles/dao_proposal.clsp b/chia/wallet/puzzles/dao_proposal.clsp deleted file mode 100644 index d490e59160a8..000000000000 --- a/chia/wallet/puzzles/dao_proposal.clsp +++ /dev/null @@ -1,377 +0,0 @@ -(mod ( - ; first hash - PROPOSAL_TIMER_MOD_HASH ; proposal timer needs to know which proposal created it - SINGLETON_MOD_HASH - LAUNCHER_PUZZLE_HASH - CAT_MOD_HASH - DAO_FINISHED_STATE_MOD_HASH - TREASURY_MOD_HASH - LOCKUP_SELF_HASH - CAT_TAIL_HASH - TREASURY_ID - ; second hash - SELF_HASH - SINGLETON_ID - PROPOSED_PUZ_HASH ; this is what runs if this proposal is successful - the inner puzzle of this proposal - YES_VOTES ; yes votes are +1, no votes don't tally - we compare yes_votes/total_votes at the end - TOTAL_VOTES ; how many people responded - ; solution - vote_amounts_or_proposal_validator_hash ; The qty of "votes" to add or subtract. ALWAYS POSITIVE. - vote_info ; vote_info is whether we are voting YES or NO. XXX rename vote_type? - vote_coin_ids_or_proposal_timelock_length ; this is either the coin ID we're taking a vote from - previous_votes_or_pass_margin ; this is the active votes of the lockup we're communicating with - ; OR this is what percentage of the total votes must be YES - represented as an integer from 0 to 10,000 - typically this is set at 5100 (51%) - lockup_innerpuzhashes_or_attendance_required ; this is either the innerpuz of the locked up CAT we're taking a vote from OR - ; the attendance required - the percentage of the current issuance which must have voted represented as 0 to 10,000 - this is announced by the treasury - innerpuz_reveal ; this is only added during the first vote - soft_close_length ; revealed by the treasury - 0 in add vote case - self_destruct_time ; revealed by the treasury - oracle_spend_delay ; used to recreate the treasury - self_destruct_flag ; if not 0, do the self-destruct spend - my_amount - ) - (include condition_codes.clib) - (include utility_macros.clib) - (include curry-and-treehash.clib) - (include *standard-cl-21*) - - (defconstant TEN_THOUSAND 10000) - - (defun is_member (e L) - (if L - (if (= e (f L)) - 1 - (is_member e (r L)) - ) - 0 - ) - ) - - (defun-inline calculate_win_percentage (TOTAL PERCENTAGE) - (f (divmod (* TOTAL PERCENTAGE) TEN_THOUSAND)) - ) - - (defun calculate_finished_state (singleton_struct DAO_FINISHED_STATE_MOD_HASH) - (puzzle-hash-of-curried-function DAO_FINISHED_STATE_MOD_HASH - (sha256 ONE DAO_FINISHED_STATE_MOD_HASH) - (sha256tree singleton_struct) - ) - ) - - (defun calculate_timer_puzhash ( - PROPOSAL_TIMER_MOD_HASH - SELF_HASH - MY_SINGLETON_STRUCT - ) - (puzzle-hash-of-curried-function PROPOSAL_TIMER_MOD_HASH - (sha256tree MY_SINGLETON_STRUCT) - (sha256 ONE SELF_HASH) - ) - ) - - (defun calculate_lockup_puzzlehash ( - LOCKUP_SELF_HASH - previous_votes - lockup_innerpuzhash - ) - (puzzle-hash-of-curried-function LOCKUP_SELF_HASH - lockup_innerpuzhash - (sha256tree previous_votes) - (sha256 ONE LOCKUP_SELF_HASH) - ) - ) - - (defun recreate_self ( - SELF_HASH - PROPOSAL_ID - PROPOSED_PUZ_HASH - YES_VOTES - TOTAL_VOTES - ) - (puzzle-hash-of-curried-function SELF_HASH - (sha256 ONE TOTAL_VOTES) - (sha256 ONE YES_VOTES) - (sha256 ONE PROPOSED_PUZ_HASH) - (sha256 ONE PROPOSAL_ID) - (sha256 ONE SELF_HASH) - ) - ) - - (defun wrap_in_cat_layer (CAT_MOD_HASH CAT_TAIL_HASH INNERPUZHASH) - (puzzle-hash-of-curried-function CAT_MOD_HASH - INNERPUZHASH - (sha256 ONE CAT_TAIL_HASH) - (sha256 ONE CAT_MOD_HASH) - ) - ) - - (defun calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree PROPOSAL_SINGLETON_STRUCT) - ) - ) - - (defun calculate_treasury_puzzlehash ( - treasury_singleton_struct - TREASURY_MOD_HASH - PROPOSAL_VALIDATOR_HASH - PROPOSAL_LENGTH - PROPOSAL_SOFTCLOSE_LENGTH - attendance_required - pass_percentage - self_destruct_time - oracle_spend_delay - ) - - (calculate_singleton_puzzle_hash treasury_singleton_struct - (puzzle-hash-of-curried-function TREASURY_MOD_HASH - (sha256 ONE oracle_spend_delay) - (sha256 ONE self_destruct_time) - (sha256 ONE pass_percentage) - (sha256 ONE attendance_required) - (sha256 ONE PROPOSAL_SOFTCLOSE_LENGTH) - (sha256 ONE PROPOSAL_LENGTH) - PROPOSAL_VALIDATOR_HASH - (sha256 ONE TREASURY_MOD_HASH) - ) - ) - ) - - (defun loop_over_vote_coins ( - SINGLETON_ID - LOCKUP_SELF_HASH - CAT_MOD_HASH - CAT_TAIL_HASH - TREASURY_ID - SELF_HASH - YES_VOTES - TOTAL_VOTES - PROPOSED_PUZ_HASH - coin_id_list - vote_amount_list - previous_votes - lockup_innerpuzhashes - vote_info - sum - output - my_amount - distinct_ids - ) - (if coin_id_list - (if (> (f vote_amount_list) 0) - (c - (list CREATE_PUZZLE_ANNOUNCEMENT (f coin_id_list)) - (c - (list - ASSERT_PUZZLE_ANNOUNCEMENT ; take the vote - (sha256 - (wrap_in_cat_layer - CAT_MOD_HASH - CAT_TAIL_HASH - (calculate_lockup_puzzlehash ; because the message comes from - LOCKUP_SELF_HASH - (f previous_votes) - (f lockup_innerpuzhashes) - ) - ) - (sha256tree (list SINGLETON_ID (f vote_amount_list) vote_info (f coin_id_list))) - ) - ) - (loop_over_vote_coins - SINGLETON_ID - LOCKUP_SELF_HASH - CAT_MOD_HASH - CAT_TAIL_HASH - TREASURY_ID - SELF_HASH - YES_VOTES - TOTAL_VOTES - PROPOSED_PUZ_HASH - (r coin_id_list) - (r vote_amount_list) - (r previous_votes) - (r lockup_innerpuzhashes) - vote_info - (+ (f vote_amount_list) sum) - output - my_amount - (if (is_member (f coin_id_list) distinct_ids) (x) (c (f coin_id_list) distinct_ids)) - ) - ) - ) - (x) - ) - (c - (list - CREATE_COIN ; recreate self with vote information added - (recreate_self - SELF_HASH - SINGLETON_ID - PROPOSED_PUZ_HASH - (if vote_info (+ YES_VOTES sum) YES_VOTES) - (+ TOTAL_VOTES sum) - ) - my_amount - (list TREASURY_ID) ; hint to Treasury ID so people can find it - ) - (c - (list ASSERT_MY_AMOUNT my_amount) - (if TOTAL_VOTES - (c (list ASSERT_HEIGHT_RELATIVE 1) output) - output - ) - ) - ) - ) - - ) - - - (if self_destruct_flag - ; assert self_destruct_time > proposal_timelock_length - ; this is the code path for if we've not been accepted by the treasury for a long time, and we're "bad" for some reason - (if (> self_destruct_time vote_coin_ids_or_proposal_timelock_length) - (list - (list CREATE_COIN (calculate_finished_state (c SINGLETON_MOD_HASH (c SINGLETON_ID LAUNCHER_PUZZLE_HASH)) DAO_FINISHED_STATE_MOD_HASH) ONE (list TREASURY_ID)) - (list ASSERT_HEIGHT_RELATIVE self_destruct_time) - (list ASSERT_PUZZLE_ANNOUNCEMENT ; make sure that we have a matching treasury oracle spend - (sha256 - (calculate_treasury_puzzlehash - (c SINGLETON_MOD_HASH (c TREASURY_ID LAUNCHER_PUZZLE_HASH)) - TREASURY_MOD_HASH - vote_amounts_or_proposal_validator_hash - vote_coin_ids_or_proposal_timelock_length ; check the veracity of these values by if the treasury uses them - soft_close_length - lockup_innerpuzhashes_or_attendance_required - previous_votes_or_pass_margin - self_destruct_time - oracle_spend_delay - ) - 0 ; the arguments are secured implicitly in the puzzle of the treasury - ) - ) - ) - (x) - ) - ; We're not trying to self destruct - ; Check whether we have a soft close to either try closing the proposal or adding votes - ; soft_close_length is used to prevent people from spamming the proposal and preventing others from being able to vote. - ; Someone could add 1 'no' vote to the proposal in every block until the proposal timelock has passed and then close the proposal as failed. - ; soft_close_length imposes some fixed number of blocks have passed without the proposal being spent before it can be closed. - ; This means there will always be some time for people to vote if they want before a proposal is closed. - (if soft_close_length - ; Add the conditions which apply in both passed and failed cases - (c - (list ASSERT_HEIGHT_RELATIVE soft_close_length) - (c - (list CREATE_COIN (calculate_finished_state (c SINGLETON_MOD_HASH (c SINGLETON_ID LAUNCHER_PUZZLE_HASH)) DAO_FINISHED_STATE_MOD_HASH) ONE (list TREASURY_ID)) - (c - (list - ASSERT_PUZZLE_ANNOUNCEMENT - (sha256 ; external timer - (calculate_timer_puzhash - PROPOSAL_TIMER_MOD_HASH - SELF_HASH - (c SINGLETON_MOD_HASH (c SINGLETON_ID LAUNCHER_PUZZLE_HASH)) - - ) - SINGLETON_ID - ) - ) - (c - (list CREATE_PUZZLE_ANNOUNCEMENT vote_coin_ids_or_proposal_timelock_length) - ; We are trying to close the proposal, so check whether it passed or failed - (if - (all - (gte TOTAL_VOTES lockup_innerpuzhashes_or_attendance_required) - (gte YES_VOTES (calculate_win_percentage TOTAL_VOTES previous_votes_or_pass_margin)) - ) - ; Passed - (list - (list CREATE_COIN_ANNOUNCEMENT (sha256tree (list PROPOSED_PUZ_HASH 0))) ; the 0 at the end is announcement_args in proposal_validators - ; the above coin annnouncement lets us validate this coin in the proposal validator - (list ASSERT_PUZZLE_ANNOUNCEMENT ; make sure that we actually have a matching treasury spend - (sha256 - (calculate_treasury_puzzlehash - (c SINGLETON_MOD_HASH (c TREASURY_ID LAUNCHER_PUZZLE_HASH)) - TREASURY_MOD_HASH - vote_amounts_or_proposal_validator_hash - vote_coin_ids_or_proposal_timelock_length ; check the veracity of these values by if the treasury uses them - soft_close_length - lockup_innerpuzhashes_or_attendance_required - previous_votes_or_pass_margin - self_destruct_time - oracle_spend_delay - ) - SINGLETON_ID ; directed at singleton, but most values are implicitly announced in the puzzle - ) - ) - ) - ; Failed - (list - (list ASSERT_PUZZLE_ANNOUNCEMENT ; make sure that we verify solution values against the treasury's oracle spend - (sha256 - (calculate_treasury_puzzlehash - (c SINGLETON_MOD_HASH (c TREASURY_ID LAUNCHER_PUZZLE_HASH)) - TREASURY_MOD_HASH - vote_amounts_or_proposal_validator_hash - vote_coin_ids_or_proposal_timelock_length ; check the veracity of these values by if the treasury uses them - soft_close_length - lockup_innerpuzhashes_or_attendance_required - previous_votes_or_pass_margin - self_destruct_time - oracle_spend_delay - ) - 0 ; the arguments are secured implicitly in the puzzle of the treasury - ) - ) - ) - ) - ) - ) - ) - ) - - - ; no soft_close_length so run the add votes path - (loop_over_vote_coins - SINGLETON_ID - LOCKUP_SELF_HASH - CAT_MOD_HASH - CAT_TAIL_HASH - TREASURY_ID - SELF_HASH - YES_VOTES - TOTAL_VOTES - PROPOSED_PUZ_HASH - vote_coin_ids_or_proposal_timelock_length - vote_amounts_or_proposal_validator_hash - previous_votes_or_pass_margin - lockup_innerpuzhashes_or_attendance_required - vote_info - 0 - (if (any YES_VOTES TOTAL_VOTES) ; this prevents the timer from being created if the coin has been created with fake votes - () - (c - (list - CREATE_COIN - (calculate_timer_puzhash - PROPOSAL_TIMER_MOD_HASH - SELF_HASH - (c SINGLETON_MOD_HASH (c SINGLETON_ID LAUNCHER_PUZZLE_HASH)) ; SINGLETON_STRUCT - ) - 0 - ) - (if (= (sha256tree innerpuz_reveal) PROPOSED_PUZ_HASH) ; reveal the proposed code on chain with the first vote - () - (x) - ) - ) - ) - my_amount - () - ) - ) - ) -) diff --git a/chia/wallet/puzzles/dao_proposal.clsp.hex b/chia/wallet/puzzles/dao_proposal.clsp.hex deleted file mode 100644 index 740585b342b7..000000000000 --- a/chia/wallet/puzzles/dao_proposal.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff8402ffffffffff01ff02ffff01ff02ffff03ffff15ff8400bfffffff8305ffff80ffff01ff02ffff01ff04ffff04ffff0133ffff04ffff02ff3cffff04ff02ffff04ffff04ff0bffff04ff8217ffff178080ffff04ff5fff8080808080ffff04ffff0101ffff04ffff04ff8205ffffff018080ffff018080808080ffff04ffff04ffff0152ffff04ff8400bfffffffff01808080ffff04ffff04ffff013fffff04ffff0bffff02ff2effff04ff02ffff04ffff04ff0bffff04ff8205ffff178080ffff04ff8200bfffff04ff83017fffffff04ff8305ffffffff04ff835fffffffff04ff8317ffffffff04ff830bffffffff04ff8400bfffffffff04ff84017fffffff808080808080808080808080ffff018080ffff01808080ffff0180808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff02ffff03ff835fffffffff01ff02ffff01ff04ffff04ffff0152ffff04ff835fffffffff01808080ffff04ffff04ffff0133ffff04ffff02ff3cffff04ff02ffff04ffff04ff0bffff04ff8217ffff178080ffff04ff5fff8080808080ffff04ffff0101ffff04ffff04ff8205ffffff018080ffff018080808080ffff04ffff04ffff013fffff04ffff0bffff02ff12ffff04ff02ffff04ff05ffff04ff820bffffff04ffff04ff0bffff04ff8217ffff178080ff808080808080ff8217ff80ffff01808080ffff04ffff04ffff013effff04ff8305ffffffff01808080ffff02ffff03ffff22ffff02ff10ffff04ff02ffff04ff8300bfffffff04ff8317ffffff8080808080ffff02ff10ffff04ff02ffff04ff825fffffff04ffff05ffff14ffff12ff8300bfffff830bffff80ffff018227108080ff808080808080ffff01ff02ffff01ff04ffff04ffff013cffff04ffff02ff14ffff04ff02ffff04ffff04ff822fffffff04ffff0180ffff01808080ff80808080ffff01808080ffff04ffff04ffff013fffff04ffff0bffff02ff2effff04ff02ffff04ffff04ff0bffff04ff8205ffff178080ffff04ff8200bfffff04ff83017fffffff04ff8305ffffffff04ff835fffffffff04ff8317ffffffff04ff830bffffffff04ff8400bfffffffff04ff84017fffffff808080808080808080808080ff8217ff80ffff01808080ffff01808080ff0180ffff01ff02ffff01ff04ffff04ffff013fffff04ffff0bffff02ff2effff04ff02ffff04ffff04ff0bffff04ff8205ffff178080ffff04ff8200bfffff04ff83017fffffff04ff8305ffffffff04ff835fffffffff04ff8317ffffffff04ff830bffffffff04ff8400bfffffffff04ff84017fffffff808080808080808080808080ffff018080ffff01808080ffff018080ff018080ff018080808080ff0180ffff01ff02ffff01ff02ff3effff04ff02ffff04ff8217ffffff04ff82017fffff04ff2fffff04ff8202ffffff04ff8205ffffff04ff820bffffff04ff825fffffff04ff8300bfffffff04ff822fffffff04ff8305ffffffff04ff83017fffffff04ff830bffffffff04ff8317ffffffff04ff8302ffffffff04ffff0180ffff04ffff02ffff03ffff21ff825fffff8300bfff80ffff01ff02ffff01ff0180ff0180ffff01ff02ffff01ff04ffff04ffff0133ffff04ffff02ff12ffff04ff02ffff04ff05ffff04ff820bffffff04ffff04ff0bffff04ff8217ffff178080ff808080808080ffff04ffff0180ffff0180808080ffff02ffff03ffff09ffff02ff14ffff04ff02ffff04ff832fffffff80808080ff822fff80ffff01ff02ffff01ff0180ff0180ffff01ff02ffff01ff0880ff018080ff018080ff018080ff0180ffff04ff8405ffffffffff04ffff0180ff808080808080808080808080808080808080808080ff018080ff0180ff018080ff0180ffff04ffff01ffffffff20ffff15ff0bff058080ffff02ffff03ff05ffff01ff02ffff01ff02ff28ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff28ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff14ffff04ff02ffff04ffff05ff0580ff80808080ffff02ff14ffff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ffff03ff0bffff01ff02ffff01ff02ffff03ffff09ff05ffff05ff0b8080ffff01ff02ffff01ff0101ff0180ffff01ff02ffff01ff02ff2cffff04ff02ffff04ff05ffff04ffff06ff0b80ff8080808080ff018080ff0180ff0180ffff01ff02ffff01ff0180ff018080ff0180ff02ff38ffff04ff02ffff04ff0bffff04ffff0bffff0101ff0b80ffff04ffff02ff14ffff04ff02ffff04ff05ff80808080ff808080808080ffffff02ff38ffff04ff02ffff04ff05ffff04ffff02ff14ffff04ff02ffff04ff17ff80808080ffff04ffff0bffff0101ff0b80ff808080808080ffff02ff38ffff04ff02ffff04ff05ffff04ff17ffff04ffff02ff14ffff04ff02ffff04ff0bff80808080ffff04ffff0bffff0101ff0580ff80808080808080ff02ff38ffff04ff02ffff04ff05ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff2f80ffff04ffff0bffff0101ff1780ffff04ffff0bffff0101ff0b80ffff04ffff0bffff0101ff0580ff808080808080808080ffffff02ff38ffff04ff02ffff04ff05ffff04ff17ffff04ffff0bffff0101ff0b80ffff04ffff0bffff0101ff0580ff80808080808080ff02ff38ffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff14ffff04ff02ffff04ff05ff80808080ff808080808080ffff02ff36ffff04ff02ffff04ff05ffff04ffff02ff38ffff04ff02ffff04ff0bffff04ffff0bffff0101ff8205ff80ffff04ffff0bffff0101ff8202ff80ffff04ffff0bffff0101ff82017f80ffff04ffff0bffff0101ff8200bf80ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff2f80ffff04ff17ffff04ffff0bffff0101ff0b80ff808080808080808080808080ff8080808080ff02ffff03ff820bffffff01ff02ffff01ff02ffff03ffff15ffff05ff8217ff80ffff018080ffff01ff02ffff01ff04ffff04ffff013effff04ffff05ff820bff80ffff01808080ffff04ffff04ffff013fffff04ffff0bffff02ff26ffff04ff02ffff04ff17ffff04ff2fffff04ffff02ff2affff04ff02ffff04ff0bffff04ffff05ff822fff80ffff04ffff05ff825fff80ff808080808080ff808080808080ffff02ff14ffff04ff02ffff04ffff04ff05ffff04ffff05ff8217ff80ffff04ff8300bfffffff04ffff05ff820bff80ffff018080808080ff8080808080ffff01808080ffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8200bfffff04ff82017fffff04ff8202ffffff04ff8205ffffff04ffff06ff820bff80ffff04ffff06ff8217ff80ffff04ffff06ff822fff80ffff04ffff06ff825fff80ffff04ff8300bfffffff04ffff10ffff05ff8217ff80ff83017fff80ffff04ff8302ffffffff04ff8305ffffffff04ffff02ffff03ffff02ff2cffff04ff02ffff04ffff05ff820bff80ffff04ff830bffffff8080808080ffff01ff02ffff01ff0880ff0180ffff01ff02ffff01ff04ffff05ff820bff80ff830bffff80ff018080ff0180ff8080808080808080808080808080808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff04ffff04ffff0133ffff04ffff02ff3affff04ff02ffff04ff8200bfffff04ff05ffff04ff8205ffffff04ffff02ffff03ff8300bfffffff01ff02ffff01ff10ff82017fff83017fff80ff0180ffff01ff02ffff0182017fff018080ff0180ffff04ffff10ff8202ffff83017fff80ff8080808080808080ffff04ff8305ffffffff04ffff04ff5fffff018080ffff018080808080ffff04ffff04ffff0149ffff04ff8305ffffffff01808080ffff02ffff03ff8202ffffff01ff02ffff01ff04ffff04ffff0152ffff04ffff0101ffff01808080ff8302ffff80ff0180ffff01ff02ffff018302ffffff018080ff01808080ff018080ff0180ff018080 diff --git a/chia/wallet/puzzles/dao_proposal.clsp.hex.sha256tree b/chia/wallet/puzzles/dao_proposal.clsp.hex.sha256tree deleted file mode 100644 index 45c30b689164..000000000000 --- a/chia/wallet/puzzles/dao_proposal.clsp.hex.sha256tree +++ /dev/null @@ -1 +0,0 @@ -a27440cdee44f910e80225592e51dc03721a9d819cc358165587fa2b34eef4cd diff --git a/chia/wallet/puzzles/dao_proposal_timer.clsp b/chia/wallet/puzzles/dao_proposal_timer.clsp deleted file mode 100644 index 5bb04bfb4960..000000000000 --- a/chia/wallet/puzzles/dao_proposal_timer.clsp +++ /dev/null @@ -1,78 +0,0 @@ -; This is a persistent timer for a proposal which allows it to have a relative time that survives despite it being recreated. -; The closing time is contained in the timelock and passed in to the solution, and confirmed via an announcement from the Proposal -; It creates/asserts announcements to pair it with the finishing spend of a proposal - -(mod ( - PROPOSAL_SELF_HASH - MY_PARENT_SINGLETON_STRUCT - proposal_yes_votes - proposal_total_votes - proposal_innerpuzhash - proposal_timelock - parent_parent - parent_amount - ) - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include *standard-cl-21*) - - (defun calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree PROPOSAL_SINGLETON_STRUCT) - ) - ) - - (defun calculate_proposal_puzzlehash ( - PROPOSAL_SINGLETON_STRUCT - PROPOSAL_SELF_HASH - proposal_yes_votes - proposal_total_votes - proposal_innerpuzhash - ) - (calculate_singleton_puzzle_hash - PROPOSAL_SINGLETON_STRUCT - (puzzle-hash-of-curried-function PROPOSAL_SELF_HASH - (sha256 ONE proposal_total_votes) - (sha256 ONE proposal_yes_votes) - (sha256 ONE proposal_innerpuzhash) - (sha256 ONE (f (r PROPOSAL_SINGLETON_STRUCT))) - (sha256 ONE PROPOSAL_SELF_HASH) - ) - ) - ) - - ; main - (list - (list ASSERT_HEIGHT_RELATIVE proposal_timelock) - (list CREATE_PUZZLE_ANNOUNCEMENT (f (r MY_PARENT_SINGLETON_STRUCT))) - (list - ASSERT_PUZZLE_ANNOUNCEMENT - (sha256 - (calculate_proposal_puzzlehash - MY_PARENT_SINGLETON_STRUCT - PROPOSAL_SELF_HASH - proposal_yes_votes - proposal_total_votes - proposal_innerpuzhash - ) - proposal_timelock - ) - ) - (list - ASSERT_MY_PARENT_ID - (sha256 - parent_parent - (calculate_proposal_puzzlehash - MY_PARENT_SINGLETON_STRUCT - PROPOSAL_SELF_HASH - 0 - 0 - proposal_innerpuzhash - ) - parent_amount - ) - - ) - ) -) diff --git a/chia/wallet/puzzles/dao_proposal_timer.clsp.hex b/chia/wallet/puzzles/dao_proposal_timer.clsp.hex deleted file mode 100644 index 06b062f73577..000000000000 --- a/chia/wallet/puzzles/dao_proposal_timer.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ffff0152ffff04ff8200bfffff01808080ffff04ffff04ffff013effff04ffff05ffff06ff0b8080ffff01808080ffff04ffff04ffff013fffff04ffff0bffff02ff1effff04ff02ffff04ff0bffff04ff05ffff04ff17ffff04ff2fffff04ff5fff8080808080808080ff8200bf80ffff01808080ffff04ffff04ffff0147ffff04ffff0bff82017fffff02ff1effff04ff02ffff04ff0bffff04ff05ffff04ffff0180ffff04ffff0180ffff04ff5fff8080808080808080ff8202ff80ffff01808080ffff018080808080ffff04ffff01ffffff02ffff03ff05ffff01ff02ffff01ff02ff08ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff08ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff0affff04ff02ffff04ffff05ff0580ff80808080ffff02ff0affff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ff0cffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff0affff04ff02ffff04ff05ff80808080ff808080808080ff02ff16ffff04ff02ffff04ff05ffff04ffff02ff0cffff04ff02ffff04ff0bffff04ffff0bffff0101ff2f80ffff04ffff0bffff0101ff1780ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff1580ffff04ffff0bffff0101ff0b80ff808080808080808080ff8080808080ff018080 diff --git a/chia/wallet/puzzles/dao_proposal_timer.clsp.hex.sha256tree b/chia/wallet/puzzles/dao_proposal_timer.clsp.hex.sha256tree deleted file mode 100644 index c642bef7fd04..000000000000 --- a/chia/wallet/puzzles/dao_proposal_timer.clsp.hex.sha256tree +++ /dev/null @@ -1 +0,0 @@ -5526d8dc33b60a23c86ac7184e8f7051515af16dbb7489555f389b84a5313c84 diff --git a/chia/wallet/puzzles/dao_proposal_validator.clsp b/chia/wallet/puzzles/dao_proposal_validator.clsp deleted file mode 100644 index 21da7b9dfab4..000000000000 --- a/chia/wallet/puzzles/dao_proposal_validator.clsp +++ /dev/null @@ -1,87 +0,0 @@ -(mod - ( - SINGLETON_STRUCT ; (SINGLETON_MOD_HASH (SINGLETON_ID . LAUNCHER_PUZZLE_HASH)) - PROPOSAL_SELF_HASH - PROPOSAL_MINIMUM_AMOUNT - PROPOSAL_EXCESS_PAYOUT_PUZ_HASH ; this is where the excess money gets paid out to - Attendance_Required ; this is passed in as a Truth from above - Pass_Margin ; this is a pass in as a Truth from above - (announcement_source delegated_puzzle_hash announcement_args) - ( - proposal_id - total_votes - yes_votes - coin_parent - coin_amount - ) - conditions - ) - - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include utility_macros.clib) - (include *standard-cl-21*) - - (defconstant TEN_THOUSAND 10000) - - (defun-inline calculate_win_percentage (TOTAL PERCENTAGE) - (f (divmod (* TOTAL PERCENTAGE) TEN_THOUSAND)) - ) - - (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (f SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree SINGLETON_STRUCT) - ) - ) - - (defun-inline calculate_proposal_puzzle ( - PROPOSAL_SELF_HASH - proposal_singleton_id - proposal_yes_votes - proposal_total_votes - proposal_innerpuz_hash - ) - (puzzle-hash-of-curried-function PROPOSAL_SELF_HASH - (sha256 ONE proposal_total_votes) - (sha256 ONE proposal_yes_votes) - (sha256 ONE proposal_innerpuz_hash) - (sha256 ONE proposal_singleton_id) - (sha256 ONE PROPOSAL_SELF_HASH) - ) - ) - - (assert - ; (= (sha256tree my_solution) announcement_args) - quex suggested this. We don't need to check it now. Can be used for future functionality. - (> (+ coin_amount ONE) PROPOSAL_MINIMUM_AMOUNT) ; >= - (gte total_votes Attendance_Required) ; TODO: we might want to change this to storing total cats and calculating like with yes votes - (gte yes_votes (calculate_win_percentage total_votes Pass_Margin)) - (= - announcement_source - (calculate_coin_id - coin_parent - (calculate_full_puzzle_hash - (c (f SINGLETON_STRUCT) (c proposal_id (r (r SINGLETON_STRUCT)))) - (calculate_proposal_puzzle - PROPOSAL_SELF_HASH - proposal_id - yes_votes ; this is where we validate the yes votes and total votes - total_votes - delegated_puzzle_hash - ) - ) - coin_amount - ) - ) - (c - (list CREATE_PUZZLE_ANNOUNCEMENT proposal_id) ; specify the proposal we're talking about - (if (> (- coin_amount 1) 0) - (c - (list CREATE_COIN PROPOSAL_EXCESS_PAYOUT_PUZ_HASH (- coin_amount 1) (list (f (r SINGLETON_STRUCT)))) - conditions - ) - conditions - ) - ) - ) -) diff --git a/chia/wallet/puzzles/dao_proposal_validator.clsp.hex b/chia/wallet/puzzles/dao_proposal_validator.clsp.hex deleted file mode 100644 index 31197eaf28ab..000000000000 --- a/chia/wallet/puzzles/dao_proposal_validator.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ffff15ffff10ff825effffff010180ff1780ffff01ff02ffff01ff02ffff03ffff02ff1effff04ff02ffff04ff820affffff04ff5fff8080808080ffff01ff02ffff01ff02ffff03ffff02ff1effff04ff02ffff04ff8216ffffff04ffff05ffff14ffff12ff820affff8200bf80ffff018227108080ff8080808080ffff01ff02ffff01ff02ffff03ffff09ff82027fffff02ff0affff04ff02ffff04ff822effffff04ffff02ff0cffff04ff02ffff04ffff05ffff04ffff05ff0580ffff04ff8204ffffff06ffff06ff058080808080ffff04ffff02ff0cffff04ff02ffff04ff0bffff04ffff0bffff0101ff820aff80ffff04ffff0bffff0101ff8216ff80ffff04ffff0bffff0101ff82057f80ffff04ffff0bffff0101ff8204ff80ffff04ffff0bffff0101ff0b80ff808080808080808080ffff04ffff02ff16ffff04ff02ffff04ffff04ffff05ff0580ffff04ff8204ffffff06ffff06ff0580808080ff80808080ff808080808080ffff04ff825effff80808080808080ffff01ff02ffff01ff04ffff04ffff013effff04ff8204ffffff01808080ffff02ffff03ffff15ffff11ff825effffff010180ffff018080ffff01ff02ffff01ff04ffff04ffff0133ffff04ff2fffff04ffff11ff825effffff010180ffff04ffff04ffff05ffff06ff058080ffff018080ffff018080808080ff8205ff80ff0180ffff01ff02ffff018205ffff018080ff018080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff04ffff01ffffff02ffff03ff05ffff01ff02ffff01ff02ff08ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff08ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ffff02ffff03ffff22ffff09ffff0dff0580ffff012080ffff09ffff0dff0b80ffff012080ffff15ff17ffff0181ff8080ffff01ff02ffff01ff0bff05ff0bff1780ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff16ffff04ff02ffff04ffff05ff0580ff80808080ffff02ff16ffff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ff20ffff15ff0bff058080ff018080 diff --git a/chia/wallet/puzzles/dao_proposal_validator.clsp.hex.sha256tree b/chia/wallet/puzzles/dao_proposal_validator.clsp.hex.sha256tree deleted file mode 100644 index dc8103326919..000000000000 --- a/chia/wallet/puzzles/dao_proposal_validator.clsp.hex.sha256tree +++ /dev/null @@ -1 +0,0 @@ -edff0f36ca097ea55c867f8700cc4d48d267b91fd00ccee2db0fab6fe0645c67 diff --git a/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp b/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp deleted file mode 100644 index 4da7df20fcb7..000000000000 --- a/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp +++ /dev/null @@ -1,240 +0,0 @@ -(mod ( - TREASURY_SINGLETON_STRUCT - CAT_MOD_HASH - CONDITIONS ; XCH conditions, to be generated by the treasury - LIST_OF_TAILHASH_CONDITIONS ; the delegated puzzlehash must be curried in to the proposal. - ; Puzzlehash is only run in the last coin for that asset - ; ((TAIL_HASH CONDITIONS) (TAIL_HASH CONDITIONS)... ) - P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH - p2_singleton_parent_amount_list ; for xch this is just a list of (coin_parent coin_amount) - p2_singleton_tailhash_parent_amount_list ; list of ((asset (parent amount) (parent amount)... ) (asset (parent amount)... )... ), - ; must match order of curryed asset list - ; the last (parent amount) gets given the puzzlehash, the rest get given 0 - treasury_inner_puzhash - ) - ; we need to track CAT_TYPE and DELEGATED_PUZZLE - ; list of (asset_type (parent amount)) - - ; If you're writing a proposal you'll want to use this layer - ; if you don't, your proposal might be invalidated if the p2_singleton coins get spent - - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include utility_macros.clib) - (include *standard-cl-21*) - - (defun-inline calculate_singleton_puzzle_hash (PROPOSAL_SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (f PROPOSAL_SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree PROPOSAL_SINGLETON_STRUCT) - ) - ) - - (defun loop_through_list ( - TREASURY_SINGLETON_STRUCT - SPEND_AMOUNT - P2_SINGLETON_PUZHASH - p2_calculated - p2_singleton_list - total - output - ) - (c - (list CREATE_PUZZLE_ANNOUNCEMENT (sha256tree (list p2_calculated (sha256tree 0)))) - (c - (list ASSERT_COIN_ANNOUNCEMENT (sha256 p2_calculated '$')) - (if p2_singleton_list - (loop_through_list - TREASURY_SINGLETON_STRUCT - SPEND_AMOUNT - P2_SINGLETON_PUZHASH - (calculate_coin_id (f (f p2_singleton_list)) P2_SINGLETON_PUZHASH (f (r (f p2_singleton_list)))) - (r p2_singleton_list) - (+ total (f (r (f p2_singleton_list)))) - output - ) - (if (> (- total SPEND_AMOUNT) 0) - (c - (list CREATE_COIN P2_SINGLETON_PUZHASH (- total SPEND_AMOUNT) (list P2_SINGLETON_PUZHASH)) - output - ) - output - ) - ) - ) - ) - ) - - (defun add_announcements_to_result (p2_calculated delegated_puzhash output) - (c - (list CREATE_PUZZLE_ANNOUNCEMENT (sha256tree (list p2_calculated delegated_puzhash))) - (c - (list ASSERT_COIN_ANNOUNCEMENT (sha256 p2_calculated '$')) - output - ) - ) - ) - - (defun sum_create_coins (conditions) - (if conditions - (+ - (if - (= (f (f conditions)) CREATE_COIN) - (if - (> (f (r (r (f conditions)))) 0) ; make an exception for -113 and other magic conditions - (f (r (r (f conditions)))) - 0 - ) - 0 - ) - (sum_create_coins (r conditions)) - ) - 0 - ) - ) - - (defun-inline calculate_delegated_puzzlehash (CONDITIONS) - (sha256tree (c ONE CONDITIONS)) ; this makes (q . CONDITIONS) - ) - - (defun wrap_in_cat_layer (CAT_MOD_HASH CAT_TAIL_HASH INNERPUZHASH) - (puzzle-hash-of-curried-function CAT_MOD_HASH - INNERPUZHASH - (sha256 ONE CAT_TAIL_HASH) - (sha256 ONE CAT_MOD_HASH) - ) - ) - - (defun dedupe ((@ lst ((@ first (parent amount)) . rest)) ids) - (if lst - (let ((id (sha256 parent amount))) - (if (in id ids) - (dedupe rest ids) - (c first (dedupe rest (c id ids))) - ) - ) - () - ) - ) - - - ; for a given asset type, loop through the cat coins and generate the announcements required for each - (defun for_each_asset ( - TREASURY_SINGLETON_STRUCT - CAT_MOD_HASH - CONDITIONS_FOR_THIS_ASSET_TYPE - P2_SINGLETON_PUZHASH - p2_singleton_puzzle_hash - parent_amount_list - total - create_coin_sum - output - ) - (if parent_amount_list - (add_announcements_to_result - (calculate_coin_id (f (f parent_amount_list)) p2_singleton_puzzle_hash (f (r (f parent_amount_list)))) - (if - (r parent_amount_list) ; this is the delegated_puzhash - (sha256tree 0) ; most coins destroy themselves - (calculate_delegated_puzzlehash ; the last coin creates the conditions - (let ((coin_sum (- (+ total (f (r (f parent_amount_list)))) create_coin_sum))) - (if (> coin_sum 0) - (c - (list CREATE_COIN P2_SINGLETON_PUZHASH coin_sum (list P2_SINGLETON_PUZHASH)) - CONDITIONS_FOR_THIS_ASSET_TYPE - ) - CONDITIONS_FOR_THIS_ASSET_TYPE - )) - ) - ) - (for_each_asset - TREASURY_SINGLETON_STRUCT - CAT_MOD_HASH - CONDITIONS_FOR_THIS_ASSET_TYPE - P2_SINGLETON_PUZHASH - p2_singleton_puzzle_hash - (r parent_amount_list) - (+ total (f (r (f parent_amount_list)))) - create_coin_sum - output - ) - ) - output - ) - ) - - ; loops through the list of ((tailhash conditions)) - (defun for_each_asset_type ( - TREASURY_SINGLETON_STRUCT - CAT_MOD_HASH - P2_SINGLETON_PUZHASH - LIST_OF_TAILHASH_CONDITIONS - p2_singleton_tailhash_parent_amount_list ; ((tailhash ((parent amount) (parent_amount)... ) (tailhash (parent amount))..) - output - ) - (if LIST_OF_TAILHASH_CONDITIONS - (for_each_asset_type - TREASURY_SINGLETON_STRUCT - CAT_MOD_HASH - P2_SINGLETON_PUZHASH - (r LIST_OF_TAILHASH_CONDITIONS) - (r p2_singleton_tailhash_parent_amount_list) - (for_each_asset - TREASURY_SINGLETON_STRUCT - CAT_MOD_HASH - (if - (= - (f (f LIST_OF_TAILHASH_CONDITIONS)) - (f (f p2_singleton_tailhash_parent_amount_list)) - ) - (f (r (f LIST_OF_TAILHASH_CONDITIONS))) - (x) ; bad solution format - ) - P2_SINGLETON_PUZHASH - (wrap_in_cat_layer CAT_MOD_HASH (f (f p2_singleton_tailhash_parent_amount_list)) P2_SINGLETON_PUZHASH) ; p2_singleton_puzzle_hash - (dedupe (f (r (f p2_singleton_tailhash_parent_amount_list))) 0 0) ; list of ((parent amount) (parent amount)...) - 0 ; current total - initialise as 0 - (sum_create_coins (f (r (f LIST_OF_TAILHASH_CONDITIONS)))) - output ; add new conditions to previous calculated output conditions - ) - ) - output ; at the end of the loop output our calculated conditions - ) - ) - - - ; main - (c - (list ASSERT_MY_PUZZLEHASH (calculate_singleton_puzzle_hash TREASURY_SINGLETON_STRUCT treasury_inner_puzhash)) - (c - (list CREATE_COIN treasury_inner_puzhash ONE (list (f (r TREASURY_SINGLETON_STRUCT)))) - (if CONDITIONS - (loop_through_list - TREASURY_SINGLETON_STRUCT - (sum_create_coins CONDITIONS) - P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH - (if p2_singleton_parent_amount_list (calculate_coin_id (f (f p2_singleton_parent_amount_list)) P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH (f (r (f p2_singleton_parent_amount_list)))) ()) - (if p2_singleton_parent_amount_list (r p2_singleton_parent_amount_list) ()) - (if p2_singleton_parent_amount_list (f (r (f p2_singleton_parent_amount_list))) ()) - (for_each_asset_type - TREASURY_SINGLETON_STRUCT - CAT_MOD_HASH - P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH - LIST_OF_TAILHASH_CONDITIONS - p2_singleton_tailhash_parent_amount_list ; ((tailhash ((parent amount) (parent_amount)... ) (tailhash (parent amount))..) - CONDITIONS - ) - ) - (for_each_asset_type - TREASURY_SINGLETON_STRUCT - CAT_MOD_HASH - P2_SINGLETON_VIA_DELEGATED_PUZZLE_PUZHASH - LIST_OF_TAILHASH_CONDITIONS - p2_singleton_tailhash_parent_amount_list ; ((tailhash ((parent amount) (parent_amount)... ) (tailhash (parent amount))..) - CONDITIONS - ) - ) - ) - ) - -) diff --git a/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex b/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex deleted file mode 100644 index dcf4a905dba0..000000000000 --- a/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ffff0148ffff04ffff02ff28ffff04ff02ffff04ffff05ff0580ffff04ff8202ffffff04ffff02ff14ffff04ff02ffff04ff05ff80808080ff808080808080ffff01808080ffff04ffff04ffff0133ffff04ff8202ffffff04ffff0101ffff04ffff04ffff05ffff06ff058080ffff018080ffff018080808080ffff02ffff03ff17ffff01ff02ffff01ff02ff3cffff04ff02ffff04ff05ffff04ffff02ff2affff04ff02ffff04ff17ff80808080ffff04ff5fffff04ffff02ffff03ff8200bfffff01ff02ffff01ff02ff38ffff04ff02ffff04ffff05ffff05ff8200bf8080ffff04ff5fffff04ffff05ffff06ffff05ff8200bf808080ff808080808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff04ffff02ffff03ff8200bfffff01ff02ffff01ff06ff8200bf80ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff04ffff02ffff03ff8200bfffff01ff02ffff01ff05ffff06ffff05ff8200bf808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff04ffff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff5fffff04ff2fffff04ff82017fffff04ff17ff808080808080808080ff80808080808080808080ff0180ffff01ff02ffff01ff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff5fffff04ff2fffff04ff82017fffff04ff17ff808080808080808080ff018080ff01808080ffff04ffff01ffffffff02ffff03ff05ffff01ff02ffff01ff02ff10ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ffff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff10ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ff02ffff03ffff22ffff09ffff0dff0580ffff012080ffff09ffff0dff0b80ffff012080ffff15ff17ffff0181ff8080ffff01ff02ffff01ff0bff05ff0bff1780ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff14ffff04ff02ffff04ffff05ff0580ff80808080ffff02ff14ffff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ffff03ff0bffff01ff02ffff01ff03ffff09ff05ffff05ff0b8080ffff0101ffff02ff2cffff04ff02ffff04ff05ffff04ffff06ff0b80ff808080808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ff04ffff04ffff013effff04ffff02ff14ffff04ff02ffff04ffff04ff2fffff04ffff02ff14ffff04ff02ffff01ff80808080ff808080ff80808080ff808080ffff04ffff04ffff013dffff04ffff0bff2fffff012480ff808080ffff02ffff03ff5fffff01ff02ffff01ff02ff3cffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ffff02ff38ffff04ff02ffff04ffff05ffff05ff5f8080ffff04ff17ffff04ffff05ffff06ffff05ff5f808080ff808080808080ffff04ffff06ff5f80ffff04ffff10ff8200bfffff05ffff06ffff05ff5f80808080ffff04ff82017fff80808080808080808080ff0180ffff01ff02ffff01ff02ffff03ffff15ffff11ff8200bfff0b80ffff018080ffff01ff02ffff01ff04ffff04ffff0133ffff04ff17ffff04ffff11ff8200bfff0b80ffff04ffff04ff17ffff018080ffff018080808080ff82017f80ff0180ffff01ff02ffff0182017fff018080ff0180ff018080ff01808080ffffff04ffff04ffff013effff04ffff02ff14ffff04ff02ffff04ffff04ff05ffff04ff0bff808080ff80808080ff808080ffff04ffff04ffff013dffff04ffff0bff05ffff012480ff808080ff178080ffff02ffff03ff05ffff01ff02ffff01ff10ffff02ffff03ffff09ffff05ffff05ff058080ffff013380ffff01ff02ffff01ff02ffff03ffff15ffff05ffff06ffff06ffff05ff0580808080ffff018080ffff01ff02ffff01ff05ffff06ffff06ffff05ff0580808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff02ff2affff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0180ff018080ff0180ff02ff28ffff04ff02ffff04ff05ffff04ff17ffff04ffff0bffff0101ff0b80ffff04ffff0bffff0101ff0580ff80808080808080ffff02ffff03ff05ffff01ff02ffff01ff02ffff03ffff02ff2cffff04ff02ffff04ffff0bff11ff2980ffff04ffff05ffff06ffff06ff01808080ff8080808080ffff01ff02ffff01ff02ff16ffff04ff02ffff04ffff06ffff05ffff06ff01808080ffff04ffff05ffff06ffff06ff01808080ff8080808080ff0180ffff01ff02ffff01ff04ffff05ffff05ffff06ff01808080ffff02ff16ffff04ff02ffff04ffff06ffff05ffff06ff01808080ffff04ffff04ffff0bff11ff2980ffff05ffff06ffff06ff0180808080ff808080808080ff018080ff0180ff0180ffff01ff02ffff01ff0180ff018080ff0180ffff02ffff03ff8200bfffff01ff02ffff01ff02ff12ffff04ff02ffff04ffff02ff38ffff04ff02ffff04ffff05ffff05ff8200bf8080ffff04ff5fffff04ffff05ffff06ffff05ff8200bf808080ff808080808080ffff04ffff02ffff03ffff06ff8200bf80ffff01ff02ffff01ff02ff14ffff04ff02ffff04ffff0180ff80808080ff0180ffff01ff02ffff01ff02ff14ffff04ff02ffff04ffff04ffff0101ffff02ffff03ffff15ffff11ffff10ff82017fffff05ffff06ffff05ff8200bf80808080ff8202ff80ffff018080ffff01ff02ffff01ff04ffff04ffff0133ffff04ffff05ffff06ffff06ffff06ffff06ff018080808080ffff04ffff11ffff10ff82017fffff05ffff06ffff05ff8200bf80808080ff8202ff80ffff04ffff04ffff05ffff06ffff06ffff06ffff06ff018080808080ffff018080ffff018080808080ffff05ffff06ffff06ffff06ff018080808080ff0180ffff01ff02ffff01ff05ffff06ffff06ffff06ff0180808080ff018080ff018080ff80808080ff018080ff0180ffff04ffff02ff2effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ffff06ff8200bf80ffff04ffff10ff82017fffff05ffff06ffff05ff8200bf80808080ffff04ff8202ffffff04ff8205ffff808080808080808080808080ff808080808080ff0180ffff01ff02ffff018205ffff018080ff0180ff02ffff03ff2fffff01ff02ffff01ff02ff3effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ffff06ff2f80ffff04ffff06ff5f80ffff04ffff02ff2effff04ff02ffff04ff05ffff04ff0bffff04ffff02ffff03ffff09ffff05ffff05ff2f8080ffff05ffff05ff5f808080ffff01ff02ffff01ff05ffff06ffff05ff2f808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff04ff17ffff04ffff02ff3affff04ff02ffff04ff0bffff04ffff05ffff05ff5f8080ffff04ff17ff808080808080ffff04ffff02ff16ffff04ff02ffff04ffff05ffff06ffff05ff5f808080ffff04ffff0180ffff04ffff0180ff808080808080ffff04ffff0180ffff04ffff02ff2affff04ff02ffff04ffff05ffff06ffff05ff2f808080ff80808080ffff04ff8200bfff808080808080808080808080ff808080808080808080ff0180ffff01ff02ffff018200bfff018080ff0180ff018080 diff --git a/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex.sha256tree b/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex.sha256tree deleted file mode 100644 index 9cde8be6a27c..000000000000 --- a/chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex.sha256tree +++ /dev/null @@ -1 +0,0 @@ -fb3890f672c9df3cc69699e21446b89b55b65071d35bf5c80a49d11c9b79a68f diff --git a/chia/wallet/puzzles/dao_treasury.clsp b/chia/wallet/puzzles/dao_treasury.clsp deleted file mode 100644 index 00f8489af42f..000000000000 --- a/chia/wallet/puzzles/dao_treasury.clsp +++ /dev/null @@ -1,115 +0,0 @@ -(mod - ( - TREASURY_MOD_HASH - PROPOSAL_VALIDATOR ; this is the curryed proposal validator - PROPOSAL_LENGTH - PROPOSAL_SOFTCLOSE_LENGTH - ATTENDANCE_REQUIRED - PASS_MARGIN ; this is a percentage 0 - 10,000 - 51% would be 5100 - PROPOSAL_SELF_DESTRUCT_TIME ; time in seconds after which proposals can be automatically closed - ORACLE_SPEND_DELAY ; timelock delay for oracle spend - (@ proposal_announcement (announcement_source delegated_puzzle_hash announcement_args)) - proposal_validator_solution - delegated_puzzle_reveal ; this is the reveal of the puzzle announced by the proposal - delegated_solution ; this is not secure unless the delegated puzzle secures it - my_singleton_struct - ) - (include utility_macros.clib) - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include *standard-cl-21*) - - (defun-inline recreate_self ( - TREASURY_MOD_HASH - PROPOSAL_VALIDATOR - PROPOSAL_LENGTH - PROPOSAL_SOFTCLOSE_LENGTH - ATTENDANCE_REQUIRED - PASS_MARGIN - PROPOSAL_SELF_DESTRUCT_TIME - ORACLE_SPEND_DELAY - ) - (puzzle-hash-of-curried-function TREASURY_MOD_HASH - (sha256 ONE ORACLE_SPEND_DELAY) - (sha256 ONE PROPOSAL_SELF_DESTRUCT_TIME) - (sha256 ONE PASS_MARGIN) - (sha256 ONE ATTENDANCE_REQUIRED) - (sha256 ONE PROPOSAL_SOFTCLOSE_LENGTH) - (sha256 ONE PROPOSAL_LENGTH) - (sha256tree PROPOSAL_VALIDATOR) - (sha256 ONE TREASURY_MOD_HASH) - ) - ) - - (defun calculate_singleton_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (f SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree SINGLETON_STRUCT) - ) - ) - - (defun stager (ORACLE_SPEND_DELAY my_inner_puzhash singleton_struct) - (c - (if singleton_struct - (list ASSERT_MY_COIN_ID - (calculate_coin_id - (f (r singleton_struct)) - (calculate_singleton_puzzle_hash singleton_struct my_inner_puzhash) - ONE - ) - ;; TODO: When the new condition codes are available, use ASSERT_EPHEMERAL to ensure this - ;; spend path is only used in the eve spend. - ;; (list ASSERT_EPHEMERAL) - ) - (list ASSERT_HEIGHT_RELATIVE ORACLE_SPEND_DELAY) - ) - (list (list CREATE_COIN my_inner_puzhash ONE)) - ) - ) - - (c - (list CREATE_PUZZLE_ANNOUNCEMENT 0) ; the arguments are secured implicitly in the puzzle of the treasury - (if delegated_puzzle_reveal - ; if we're checking a proposal (testing if it has passed) - (if (= (sha256tree delegated_puzzle_reveal) delegated_puzzle_hash) - ; Merge the treasury conditions with the proposal validator conditions - ; If the update case then the validator returns the new treasury create coin - ; If the spend case then we need to recreate the treasury outselves - ; treasury specific conditions - - (c - (list ASSERT_COIN_ANNOUNCEMENT (sha256 announcement_source (sha256tree (list delegated_puzzle_hash announcement_args)))) ; announcement source is validated inside the ProposalValidator - (c - (list ASSERT_HEIGHT_RELATIVE 1) - (a - PROPOSAL_VALIDATOR - (list - ATTENDANCE_REQUIRED - PASS_MARGIN - proposal_announcement - proposal_validator_solution - (a delegated_puzzle_reveal delegated_solution) - ) - ) - ) - ) - (x) - ) - ; no proposal_flag so create the oracle announcement - (stager - ORACLE_SPEND_DELAY - (recreate_self - TREASURY_MOD_HASH - PROPOSAL_VALIDATOR - PROPOSAL_LENGTH - PROPOSAL_SOFTCLOSE_LENGTH - ATTENDANCE_REQUIRED - PASS_MARGIN - PROPOSAL_SELF_DESTRUCT_TIME - ORACLE_SPEND_DELAY - ) - my_singleton_struct - ) - ) - ) -) diff --git a/chia/wallet/puzzles/dao_treasury.clsp.hex b/chia/wallet/puzzles/dao_treasury.clsp.hex deleted file mode 100644 index 3b6bba294d29..000000000000 --- a/chia/wallet/puzzles/dao_treasury.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ffff013effff04ffff0180ffff01808080ffff02ffff03ff8217ffffff01ff02ffff01ff02ffff03ffff09ffff02ff0affff04ff02ffff04ff8217ffff80808080ff8215ff80ffff01ff02ffff01ff04ffff04ffff013dffff04ffff0bff8209ffffff02ff0affff04ff02ffff04ffff04ff8215ffffff04ff822dffffff01808080ff8080808080ffff01808080ffff04ffff04ffff0152ffff04ffff0101ffff01808080ffff02ff0bffff04ff5fffff04ff8200bfffff04ff8205ffffff04ff820bffffff04ffff02ff8217ffff822fff80ffff01808080808080808080ff0180ffff01ff02ffff01ff0880ff018080ff0180ff0180ffff01ff02ffff01ff02ff1effff04ff02ffff04ff8202ffffff04ffff02ff14ffff04ff02ffff04ff05ffff04ffff0bffff0101ff8202ff80ffff04ffff0bffff0101ff82017f80ffff04ffff0bffff0101ff8200bf80ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff2f80ffff04ffff0bffff0101ff1780ffff04ffff02ff0affff04ff02ffff04ff0bff80808080ffff04ffff0bffff0101ff0580ff808080808080808080808080ffff04ff825fffff808080808080ff018080ff018080ffff04ffff01ffffff02ffff03ff05ffff01ff02ffff01ff02ff08ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ffff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff08ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ff02ffff03ffff22ffff09ffff0dff0580ffff012080ffff09ffff0dff0b80ffff012080ffff15ff17ffff0181ff8080ffff01ff02ffff01ff0bff05ff0bff1780ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff0affff04ff02ffff04ffff05ff0580ff80808080ffff02ff0affff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ffff02ff14ffff04ff02ffff04ff09ffff04ff0bffff04ffff02ff0affff04ff02ffff04ff05ff80808080ff808080808080ff04ffff02ffff03ff17ffff01ff02ffff01ff04ffff0146ffff04ffff02ff1cffff04ff02ffff04ffff05ffff06ff178080ffff04ffff02ff16ffff04ff02ffff04ff17ffff04ff0bff8080808080ffff04ffff0101ff808080808080ffff01808080ff0180ffff01ff02ffff01ff04ffff0152ffff04ff05ffff01808080ff018080ff0180ffff04ffff04ffff0133ffff04ff0bffff01ff01808080ff808080ff018080 diff --git a/chia/wallet/puzzles/dao_update_proposal.clsp b/chia/wallet/puzzles/dao_update_proposal.clsp deleted file mode 100644 index cbbdc8defb8a..000000000000 --- a/chia/wallet/puzzles/dao_update_proposal.clsp +++ /dev/null @@ -1,44 +0,0 @@ -(mod - ( - TREASURY_MOD_HASH - VALIDATOR_MOD_HASH - SINGLETON_STRUCT ; (SINGLETON_MOD_HASH (SINGLETON_ID . LAUNCHER_PUZZLE_HASH)) - PROPOSAL_SELF_HASH - PROPOSAL_MINIMUM_AMOUNT - PROPOSAL_EXCESS_PAYOUT_PUZHASH - PROPOSAL_LENGTH - PROPOSAL_SOFTCLOSE_LENGTH - ATTENDANCE_REQUIRED - PASS_MARGIN - PROPOSAL_SELF_DESTRUCT_TIME - ORACLE_SPEND_DELAY - ) - ;; This is a proposal to update treasury conditions for a DAO - - - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include *standard-cl-21*) - (include utility_macros.clib) - - (list - (list CREATE_COIN - (puzzle-hash-of-curried-function TREASURY_MOD_HASH - (sha256 ONE ORACLE_SPEND_DELAY) - (sha256 ONE PROPOSAL_SELF_DESTRUCT_TIME) - (sha256 ONE PASS_MARGIN) - (sha256 ONE ATTENDANCE_REQUIRED) - (sha256 ONE PROPOSAL_SOFTCLOSE_LENGTH) - (sha256 ONE PROPOSAL_LENGTH) - (puzzle-hash-of-curried-function VALIDATOR_MOD_HASH - (sha256 ONE PROPOSAL_EXCESS_PAYOUT_PUZHASH) - (sha256 ONE PROPOSAL_MINIMUM_AMOUNT) - (sha256 ONE PROPOSAL_SELF_HASH) - (sha256tree SINGLETON_STRUCT) - ) - (sha256 ONE TREASURY_MOD_HASH) - ) - ONE - ) - ) -) diff --git a/chia/wallet/puzzles/dao_update_proposal.clsp.hex b/chia/wallet/puzzles/dao_update_proposal.clsp.hex deleted file mode 100644 index 6c6608d9f909..000000000000 --- a/chia/wallet/puzzles/dao_update_proposal.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ffff0133ffff04ffff02ff0affff04ff02ffff04ff05ffff04ffff0bffff0101ff822fff80ffff04ffff0bffff0101ff8217ff80ffff04ffff0bffff0101ff820bff80ffff04ffff0bffff0101ff8205ff80ffff04ffff0bffff0101ff8202ff80ffff04ffff0bffff0101ff82017f80ffff04ffff02ff0affff04ff02ffff04ff0bffff04ffff0bffff0101ff8200bf80ffff04ffff0bffff0101ff5f80ffff04ffff0bffff0101ff2f80ffff04ffff02ff0effff04ff02ffff04ff17ff80808080ff8080808080808080ffff04ffff0bffff0101ff0580ff808080808080808080808080ffff04ffff0101ffff0180808080ffff018080ffff04ffff01ffff02ffff03ff05ffff01ff02ffff01ff02ff04ffff04ff02ffff04ffff06ff0580ffff04ffff0bffff0102ffff0bffff0101ffff010480ffff0bffff0102ffff0bffff0102ffff0bffff0101ffff010180ffff05ff058080ffff0bffff0102ff0bffff0bffff0101ffff018080808080ff8080808080ff0180ffff01ff02ffff010bff018080ff0180ffff0bffff0102ffff01a0a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222ffff0bffff0102ffff0bffff0102ffff01a09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ff0580ffff0bffff0102ffff02ff04ffff04ff02ffff04ff07ffff01ffa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b280808080ffff01a04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a808080ff02ffff03ffff07ff0580ffff01ff02ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ffff05ff0580ff80808080ffff02ff0effff04ff02ffff04ffff06ff0580ff8080808080ff0180ffff01ff02ffff01ff0bffff0101ff0580ff018080ff0180ff018080 diff --git a/chia/wallet/puzzles/json.clib b/chia/wallet/puzzles/json.clib deleted file mode 100644 index e25e1b769315..000000000000 --- a/chia/wallet/puzzles/json.clib +++ /dev/null @@ -1,25 +0,0 @@ -( - - (defun search_list_then_resume (key json_object result) - (if result - result - (search_for_value_given_key key (r json_object)) - ) - ) - - (defun search_for_value_given_key (key json_object) - (if json_object - (if (l (f from_json_dict)) ; if we are hitting an unlabelled item (atom), just move on - (if (= (f (f json_object)) key) ; if we have found our key - (r (f json_object)) ; return the value - (if (l (r (f json_object))) ; otherwise check if we have hit another dictionary - (search_list_then_resume key json_object (search_for_value_given_key key (r (f json_object)))) ; check new dictionary - (search_for_value_given_key key (r json_object)) - ) - ) - (search_for_value_given_key key (r json_object)) - ) - () - ) - ) -) diff --git a/chia/wallet/puzzles/merkle_utils.clib b/chia/wallet/puzzles/merkle_utils.clib deleted file mode 100644 index 97e1f4046593..000000000000 --- a/chia/wallet/puzzles/merkle_utils.clib +++ /dev/null @@ -1,18 +0,0 @@ -( - (defun simplify_merkle_proof_after_leaf (leaf_hash (bitpath . hashes_path)) - (if hashes_path - (simplify_merkle_proof_after_leaf - (if (logand 1 bitpath) - (sha256 0x02 (f hashes_path) leaf_hash) - (sha256 0x02 leaf_hash (f hashes_path)) - ) - (c (lsh bitpath -1) (r hashes_path)) - ) - leaf_hash - ) - ) - - (defun-inline simplify_merkle_proof (leaf proof) - (simplify_merkle_proof_after_leaf (sha256 0x01 leaf) proof) - ) -) diff --git a/chia/wallet/puzzles/notification.clsp b/chia/wallet/puzzles/notification.clsp deleted file mode 100644 index ef01b3ebd303..000000000000 --- a/chia/wallet/puzzles/notification.clsp +++ /dev/null @@ -1,7 +0,0 @@ -(mod ( - TARGET - AMOUNT - ) - (include condition_codes.clib) - (list (list CREATE_COIN TARGET AMOUNT) (list CREATE_COIN_ANNOUNCEMENT ())) -) diff --git a/chia/wallet/puzzles/notification.clsp.hex b/chia/wallet/puzzles/notification.clsp.hex deleted file mode 100644 index 9817f548518b..000000000000 --- a/chia/wallet/puzzles/notification.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff04ffff04ff05ffff04ff0bff80808080ffff04ffff04ff06ffff01ff808080ff808080ffff04ffff01ff333cff018080 diff --git a/chia/wallet/puzzles/p2_1_of_n.clsp b/chia/wallet/puzzles/p2_1_of_n.clsp deleted file mode 100644 index 55d8dc487a5b..000000000000 --- a/chia/wallet/puzzles/p2_1_of_n.clsp +++ /dev/null @@ -1,22 +0,0 @@ -(mod - ( - MERKLE_ROOT - merkle_proof - puzzle_to_execute - inner_solution - ) - - (include utility_macros.clib) - (include merkle_utils.clib) - - ; takes a lisp tree and returns the hash of it - (defun sha256tree (TREE) - (if (l TREE) - (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE))) - (sha256 1 TREE))) - - (assert (= MERKLE_ROOT (simplify_merkle_proof (sha256tree puzzle_to_execute) merkle_proof)) - (a puzzle_to_execute inner_solution) - ) - -) diff --git a/chia/wallet/puzzles/p2_1_of_n.clsp.hex b/chia/wallet/puzzles/p2_1_of_n.clsp.hex deleted file mode 100644 index 64d9ffda2ae8..000000000000 --- a/chia/wallet/puzzles/p2_1_of_n.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ffff09ff05ffff02ff06ffff04ff02ffff04ffff0bffff0101ffff02ff04ffff04ff02ffff04ff17ff8080808080ffff04ff0bff808080808080ffff01ff02ff17ff2f80ffff01ff088080ff0180ffff04ffff01ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff04ffff04ff02ffff04ff09ff80808080ffff02ff04ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ff1bffff01ff02ff06ffff04ff02ffff04ffff02ffff03ffff18ffff0101ff1380ffff01ff0bffff0102ff2bff0580ffff01ff0bffff0102ff05ff2b8080ff0180ffff04ffff04ffff17ff13ffff0181ff80ff3b80ff8080808080ffff010580ff0180ff018080 diff --git a/chia/wallet/puzzles/p2_conditions.clsp b/chia/wallet/puzzles/p2_conditions.clsp deleted file mode 100644 index 2463aa3be5f6..000000000000 --- a/chia/wallet/puzzles/p2_conditions.clsp +++ /dev/null @@ -1,3 +0,0 @@ -(mod (conditions) - (qq (q . (unquote conditions))) -) diff --git a/chia/wallet/puzzles/p2_conditions.clsp.hex b/chia/wallet/puzzles/p2_conditions.clsp.hex deleted file mode 100644 index 4183117a3591..000000000000 --- a/chia/wallet/puzzles/p2_conditions.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff04ffff0101ff0280 diff --git a/chia/wallet/puzzles/p2_conditions.py b/chia/wallet/puzzles/p2_conditions.py index be23c0d39e83..8f227a715bd3 100644 --- a/chia/wallet/puzzles/p2_conditions.py +++ b/chia/wallet/puzzles/p2_conditions.py @@ -12,10 +12,11 @@ from __future__ import annotations +from chia_puzzles_py.programs import P2_CONDITIONS + from chia.types.blockchain_format.program import Program -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile -MOD = load_clvm_maybe_recompile("p2_conditions.clsp") +MOD = Program.from_bytes(P2_CONDITIONS) def puzzle_for_conditions(conditions) -> Program: diff --git a/chia/wallet/puzzles/p2_delegated_conditions.clsp b/chia/wallet/puzzles/p2_delegated_conditions.clsp deleted file mode 100644 index 5be64e2deaca..000000000000 --- a/chia/wallet/puzzles/p2_delegated_conditions.clsp +++ /dev/null @@ -1,18 +0,0 @@ -(mod - (public_key conditions) - - (include condition_codes.clib) - - ;; hash a tree - ;; This is used to calculate a puzzle hash given a puzzle program. - (defun sha256tree1 - (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE) - ) - ) - - (c (list AGG_SIG_ME public_key (sha256tree1 conditions)) conditions) - -) diff --git a/chia/wallet/puzzles/p2_delegated_conditions.clsp.hex b/chia/wallet/puzzles/p2_delegated_conditions.clsp.hex deleted file mode 100644 index 46f9abe76535..000000000000 --- a/chia/wallet/puzzles/p2_delegated_conditions.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff0bff80808080ff80808080ff0b80ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/p2_delegated_conditions.py b/chia/wallet/puzzles/p2_delegated_conditions.py index a17cf9008bf2..2e7cc8e1ffc5 100644 --- a/chia/wallet/puzzles/p2_delegated_conditions.py +++ b/chia/wallet/puzzles/p2_delegated_conditions.py @@ -7,10 +7,11 @@ from __future__ import annotations +from chia_puzzles_py.programs import P2_DELEGATED_CONDITIONS + from chia.types.blockchain_format.program import Program -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile -MOD = load_clvm_maybe_recompile("p2_delegated_conditions.clsp") +MOD = Program.from_bytes(P2_DELEGATED_CONDITIONS) def puzzle_for_pk(public_key: Program) -> Program: diff --git a/chia/wallet/puzzles/p2_delegated_puzzle.clsp b/chia/wallet/puzzles/p2_delegated_puzzle.clsp deleted file mode 100644 index f995603dab52..000000000000 --- a/chia/wallet/puzzles/p2_delegated_puzzle.clsp +++ /dev/null @@ -1,19 +0,0 @@ -(mod - - (public_key delegated_puzzle delegated_puzzle_solution) - - (include condition_codes.clib) - - ;; hash a tree - ;; This is used to calculate a puzzle hash given a puzzle program. - (defun sha256tree1 - (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE) - ) - ) - - (c (list AGG_SIG_ME public_key (sha256tree1 delegated_puzzle)) - (a delegated_puzzle delegated_puzzle_solution)) -) diff --git a/chia/wallet/puzzles/p2_delegated_puzzle.clsp.hex b/chia/wallet/puzzles/p2_delegated_puzzle.clsp.hex deleted file mode 100644 index 2bded53faacb..000000000000 --- a/chia/wallet/puzzles/p2_delegated_puzzle.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff0bff80808080ff80808080ffff02ff0bff178080ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/p2_delegated_puzzle.py b/chia/wallet/puzzles/p2_delegated_puzzle.py index 680031836019..82c269af5ed7 100644 --- a/chia/wallet/puzzles/p2_delegated_puzzle.py +++ b/chia/wallet/puzzles/p2_delegated_puzzle.py @@ -14,11 +14,12 @@ from __future__ import annotations +from chia_puzzles_py.programs import P2_DELEGATED_PUZZLE + from chia.types.blockchain_format.program import Program from chia.wallet.puzzles import p2_conditions -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile -MOD = load_clvm_maybe_recompile("p2_delegated_puzzle.clsp") +MOD = Program.from_bytes(P2_DELEGATED_PUZZLE) def puzzle_for_pk(public_key: bytes) -> Program: diff --git a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp b/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp deleted file mode 100644 index 47b01797a1f0..000000000000 --- a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp +++ /dev/null @@ -1,91 +0,0 @@ -; build a pay-to delegated puzzle or hidden puzzle -; coins can be unlocked by signing a delegated puzzle and its solution -; OR by revealing the hidden puzzle and the underlying original key - -; glossary of parameter names: - -; hidden_puzzle: a "hidden puzzle" that can be revealed and used as an alternate -; way to unlock the underlying funds -; -; synthetic_key_offset: a private key cryptographically generated using the hidden -; puzzle and as inputs `original_public_key` -; -; SYNTHETIC_PUBLIC_KEY: the public key that is the sum of `original_public_key` and the -; public key corresponding to `synthetic_key_offset` -; -; original_public_key: a public key, where knowledge of the corresponding private key -; represents ownership of the file -; -; delegated_puzzle: a delegated puzzle, as in "graftroot", which should return the -; desired conditions. -; -; solution: the solution to the delegated puzzle - - -(mod - ; A puzzle should commit to `SYNTHETIC_PUBLIC_KEY` - ; - ; The solution should pass in 0 for `original_public_key` if it wants to use - ; an arbitrary `delegated_puzzle` (and `solution`) signed by the - ; `SYNTHETIC_PUBLIC_KEY` (whose corresponding private key can be calculated - ; if you know the private key for `original_public_key`) - ; - ; Or you can solve the hidden puzzle by revealing the `original_public_key`, - ; the hidden puzzle in `delegated_puzzle`, and a solution to the hidden puzzle. - - (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle solution) - - ; "assert" is a macro that wraps repeated instances of "if" - ; usage: (assert A0 A1 ... An R) - ; all of A0, A1, ... An must evaluate to non-null, or an exception is raised - ; return the value of R (if we get that far) - - (defmacro assert items - (if (r items) - (list if (f items) (c assert (r items)) (q . (x))) - (f items) - ) - ) - - (include condition_codes.clib) - - ;; hash a tree - ;; This is used to calculate a puzzle hash given a puzzle program. - (defun sha256tree1 - (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE) - ) - ) - - ; "is_hidden_puzzle_correct" returns true iff the hidden puzzle is correctly encoded - - (defun-inline is_hidden_puzzle_correct (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle) - (= - SYNTHETIC_PUBLIC_KEY - (point_add - original_public_key - (pubkey_for_exp (sha256 original_public_key (sha256tree1 delegated_puzzle))) - ) - ) - ) - - ; "possibly_prepend_aggsig" is the main entry point - - (defun-inline possibly_prepend_aggsig (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle conditions) - (if original_public_key - (assert - (is_hidden_puzzle_correct SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle) - conditions - ) - (c (list AGG_SIG_ME SYNTHETIC_PUBLIC_KEY (sha256tree1 delegated_puzzle)) conditions) - ) - ) - - ; main entry point - - (possibly_prepend_aggsig - SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle - (a delegated_puzzle solution)) -) diff --git a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp.hex b/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp.hex deleted file mode 100644 index 4d96fe6ce5a2..000000000000 --- a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff0bffff01ff02ffff03ffff09ff05ffff1dff0bffff1effff0bff0bffff02ff06ffff04ff02ffff04ff17ff8080808080808080ffff01ff02ff17ff2f80ffff01ff088080ff0180ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff17ff80808080ff80808080ffff02ff17ff2f808080ff0180ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 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 f174681d2686..b2ec3973377a 100644 --- a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +++ b/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py @@ -62,12 +62,12 @@ from functools import lru_cache from typing import Union +from chia_puzzles_py.programs import P2_DELEGATED_PUZZLE_OR_HIDDEN_PUZZLE from chia_rs import G1Element, PrivateKey from clvm.casts import int_from_bytes from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.puzzles.p2_conditions import puzzle_for_conditions from chia.wallet.util.curry_and_treehash import calculate_hash_of_quoted_mod_hash, curry_and_treehash, shatree_atom @@ -75,7 +75,7 @@ DEFAULT_HIDDEN_PUZZLE_HASH = DEFAULT_HIDDEN_PUZZLE.get_tree_hash() # this puzzle `(=)` always fails -MOD = load_clvm_maybe_recompile("p2_delegated_puzzle_or_hidden_puzzle.clsp") +MOD = Program.from_bytes(P2_DELEGATED_PUZZLE_OR_HIDDEN_PUZZLE) QUOTED_MOD_HASH = calculate_hash_of_quoted_mod_hash(MOD.get_tree_hash()) diff --git a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp b/chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp deleted file mode 100644 index b23eb826fe31..000000000000 --- a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp +++ /dev/null @@ -1,108 +0,0 @@ -; build an M of N multisig puzzle -; coins are locked by N public keys, any M of which can delegate a sub-puzzle - - -; glossary of parameter names: - -; public_key_list: a list of N public keys - -; M: the M in "M of N" - -; selectors: a list up of 0s and 1s up to size N where exactly M are 1s -; It's used to select public keys from public_key_list - -; delegated_puzzle: the puzzle signed by the M public keys -; This puzzle must return a list of conditions - -; solution: the solution to the delegated puzzle - - -(mod - (M public_key_list selectors delegated_puzzle solution) - - (include condition_codes.clib) - - ;; hash a tree - ;; This is used to calculate a puzzle hash given a puzzle program. - (defun sha256tree1 - (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE) - ) - ) - - ; "assert" is a macro that wraps repeated instances of "if" - ; usage: (assert A0 A1 ... An R) - ; all of A0, A1, ... An must evaluate to non-null, or an exception is raised - ; return the value of R (if we get that far) - - (defmacro assert items - (if (r items) - (list if (f items) (c assert (r items)) (q . (x))) - (f items) - ) - ) - - ; add_aggsig returns a list of conditions. It includes M AGG_SIG conditions - ; corresponding to the given list of public keys (with the given hash) - ; plus the conditions that come out of the delegated puzzle. - ; - ; hash is the hash of delegated_puzzle. - ; Yes it's redundant since we include the delegated_puzzle itself, - ; but we don't want to recalculate the hash multiple times as its expensive to do so - - (defun add_aggsig (public_key_list hash delegated_puzzle solution) - (if public_key_list - (c (list AGG_SIG_UNSAFE (f public_key_list) hash) - (add_aggsig (r public_key_list) hash delegated_puzzle solution) - ) - (a delegated_puzzle solution) - ) - ) - - ; choose_keys takes a list of selectors and the N public keys and - ; returns a list of the M public keys chosen by the selectors - - (defun choose_keys (selectors public_key_list) - (if selectors - (if (f selectors) - (c (f public_key_list) (choose_keys (r selectors) (r public_key_list))) - (choose_keys (r selectors) (r public_key_list))) - () - ) - ) - - - ; count the number of non-0 values in the list of selectors and return it as an integer - - (defun count_selectors (selectors) - (if selectors - (+ - (count_selectors (r selectors)) - (if (f selectors) 1 0) - ) - 0 - ) - ) - - ; "solve_puzzle" is the main entry point - - (defun-inline solve_puzzle (M public_key_list selectors delegated_puzzle solution) - ; make sure we have exactly M selectors - (assert (= M (count_selectors selectors)) - ; return the AGG_SIG conditions plus the conditions from the delegated_puzzle - (add_aggsig (choose_keys selectors public_key_list) - (sha256tree1 delegated_puzzle) - delegated_puzzle - solution) - ) - ) - - ; main entry point - - (solve_puzzle - M public_key_list - selectors delegated_puzzle solution - ) -) diff --git a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp.hex b/chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp.hex deleted file mode 100644 index 75d2306362d1..000000000000 --- a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ffff09ff05ffff02ff16ffff04ff02ffff04ff17ff8080808080ffff01ff02ff0cffff04ff02ffff04ffff02ff0affff04ff02ffff04ff17ffff04ff0bff8080808080ffff04ffff02ff1effff04ff02ffff04ff2fff80808080ffff04ff2fffff04ff5fff80808080808080ffff01ff088080ff0180ffff04ffff01ffff31ff02ffff03ff05ffff01ff04ffff04ff08ffff04ff09ffff04ff0bff80808080ffff02ff0cffff04ff02ffff04ff0dffff04ff0bffff04ff17ffff04ff2fff8080808080808080ffff01ff02ff17ff2f8080ff0180ffff02ffff03ff05ffff01ff02ffff03ff09ffff01ff04ff13ffff02ff0affff04ff02ffff04ff0dffff04ff1bff808080808080ffff01ff02ff0affff04ff02ffff04ff0dffff04ff1bff808080808080ff0180ff8080ff0180ffff02ffff03ff05ffff01ff10ffff02ff16ffff04ff02ffff04ff0dff80808080ffff02ffff03ff09ffff01ff0101ff8080ff018080ff8080ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 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 707db15a47ac..e7a40ea900af 100644 --- a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py +++ b/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py @@ -7,10 +7,11 @@ from __future__ import annotations +from chia_puzzles_py.programs import P2_M_OF_N_DELEGATE_DIRECT + from chia.types.blockchain_format.program import Program -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile -MOD = load_clvm_maybe_recompile("p2_m_of_n_delegate_direct.clsp") +MOD = Program.from_bytes(P2_M_OF_N_DELEGATE_DIRECT) def puzzle_for_m_of_public_key_list(m, public_key_list) -> Program: diff --git a/chia/wallet/puzzles/p2_parent.clsp b/chia/wallet/puzzles/p2_parent.clsp deleted file mode 100644 index 07f55fb4a42e..000000000000 --- a/chia/wallet/puzzles/p2_parent.clsp +++ /dev/null @@ -1,19 +0,0 @@ -(mod - ( - MORPHER ; For no morphing, 1 - parent_parent_id - parent_inner_puz - parent_amount - parent_solution - ) - - (include condition_codes.clib) - (include curry-and-treehash.clib) - - (c - (list ASSERT_MY_PARENT_ID - (calculate_coin_id parent_parent_id (a MORPHER (sha256tree parent_inner_puz)) parent_amount) - ) - (a parent_inner_puz parent_solution) - ) -) diff --git a/chia/wallet/puzzles/p2_parent.clsp.hex b/chia/wallet/puzzles/p2_parent.clsp.hex deleted file mode 100644 index 135284ca79ad..000000000000 --- a/chia/wallet/puzzles/p2_parent.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff08ffff04ffff02ff0affff04ff02ffff04ff0bffff04ffff02ff05ffff02ff0effff04ff02ffff04ff17ff8080808080ffff04ff2fff808080808080ff808080ffff02ff17ff5f8080ffff04ffff01ffff4720ffff02ffff03ffff22ffff09ffff0dff0580ff0c80ffff09ffff0dff0b80ff0c80ffff15ff17ffff0181ff8080ffff01ff0bff05ff0bff1780ffff01ff088080ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ff09ff80808080ffff02ff0effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/p2_puzzle_hash.clsp b/chia/wallet/puzzles/p2_puzzle_hash.clsp deleted file mode 100644 index 7e2ca1e3620f..000000000000 --- a/chia/wallet/puzzles/p2_puzzle_hash.clsp +++ /dev/null @@ -1,18 +0,0 @@ -(mod - (inner_puzzle_hash inner_puzzle inner_puzzle_solution) - - ;; hash a tree - ;; This is used to calculate a puzzle hash given a puzzle program. - (defun sha256tree1 - (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE) - ) - ) - - (if (= inner_puzzle_hash (sha256tree1 inner_puzzle)) - (a inner_puzzle inner_puzzle_solution) - (x) - ) -) diff --git a/chia/wallet/puzzles/p2_puzzle_hash.clsp.hex b/chia/wallet/puzzles/p2_puzzle_hash.clsp.hex deleted file mode 100644 index 9f7f8c09692b..000000000000 --- a/chia/wallet/puzzles/p2_puzzle_hash.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ffff09ff05ffff02ff02ffff04ff02ffff04ff0bff8080808080ffff01ff02ff0bff1780ffff01ff088080ff0180ffff04ffff01ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff02ffff04ff02ffff04ff09ff80808080ffff02ff02ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/p2_puzzle_hash.py b/chia/wallet/puzzles/p2_puzzle_hash.py index 1953c9d5fb32..008a5e1c4052 100644 --- a/chia/wallet/puzzles/p2_puzzle_hash.py +++ b/chia/wallet/puzzles/p2_puzzle_hash.py @@ -7,11 +7,12 @@ from __future__ import annotations +from chia_puzzles_py.programs import P2_PUZZLE_HASH + from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile -MOD = load_clvm_maybe_recompile("p2_puzzle_hash.clsp") +MOD = Program.from_bytes(P2_PUZZLE_HASH) def puzzle_for_inner_puzzle_hash(inner_puzzle_hash: bytes32) -> Program: diff --git a/chia/wallet/puzzles/p2_singleton.clsp b/chia/wallet/puzzles/p2_singleton.clsp deleted file mode 100644 index 47d63a99dcce..000000000000 --- a/chia/wallet/puzzles/p2_singleton.clsp +++ /dev/null @@ -1,30 +0,0 @@ -(mod (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash my_id) - - ; SINGLETON_MOD_HASH is the mod-hash for the singleton_top_layer puzzle - ; LAUNCHER_ID is the ID of the singleton we are committed to paying to - ; LAUNCHER_PUZZLE_HASH is the puzzle hash of the launcher - ; singleton_inner_puzzle_hash is the innerpuzzlehash for our singleton at the current time - ; my_id is the coin_id of the coin that this puzzle is locked into - - (include condition_codes.clib) - (include curry-and-treehash.clib) - - ;; return the full puzzlehash for a singleton with the innerpuzzle curried in - ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib - (defun-inline calculate_full_puzzle_hash (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH inner_puzzle_hash) - (puzzle-hash-of-curried-function SINGLETON_MOD_HASH - inner_puzzle_hash - (sha256tree (c SINGLETON_MOD_HASH (c LAUNCHER_ID LAUNCHER_PUZZLE_HASH))) - ) - ) - - (defun-inline claim_rewards (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash my_id) - (list - (list ASSERT_PUZZLE_ANNOUNCEMENT (sha256 (calculate_full_puzzle_hash SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash) my_id)) - (list CREATE_COIN_ANNOUNCEMENT '$') - (list ASSERT_MY_COIN_ID my_id)) - ) - - ; main - (claim_rewards SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash my_id) -) diff --git a/chia/wallet/puzzles/p2_singleton.clsp.hex b/chia/wallet/puzzles/p2_singleton.clsp.hex deleted file mode 100644 index 9e13d6004a3c..000000000000 --- a/chia/wallet/puzzles/p2_singleton.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff18ffff04ffff0bffff02ff2effff04ff02ffff04ff05ffff04ff2fffff04ffff02ff3effff04ff02ffff04ffff04ff05ffff04ff0bff178080ff80808080ff808080808080ff5f80ff808080ffff04ffff04ff2cffff01ff248080ffff04ffff04ff10ffff04ff5fff808080ff80808080ffff04ffff01ffffff463fff02ff3c04ffff01ff0102ffff02ffff03ff05ffff01ff02ff16ffff04ff02ffff04ff0dffff04ffff0bff3affff0bff12ff3c80ffff0bff3affff0bff3affff0bff12ff2a80ff0980ffff0bff3aff0bffff0bff12ff8080808080ff8080808080ffff010b80ff0180ffff0bff3affff0bff12ff1480ffff0bff3affff0bff3affff0bff12ff2a80ff0580ffff0bff3affff02ff16ffff04ff02ffff04ff07ffff04ffff0bff12ff1280ff8080808080ffff0bff12ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/p2_singleton_aggregator.clsp b/chia/wallet/puzzles/p2_singleton_aggregator.clsp deleted file mode 100644 index 17d03dd596e6..000000000000 --- a/chia/wallet/puzzles/p2_singleton_aggregator.clsp +++ /dev/null @@ -1,81 +0,0 @@ -;; Works with p2_singleton_via_delegated_puzzle -;; When we have many p2_singleton coins and want to aggregate them together - -;; all coins make announcements of their puzhash, amount, and ID -;; the aggregator coin (the one creating the output) creates an announcement of the ID of each merge coin -;; each merge coin asserts that the aggregator has an announcement of their (the merge coin's) ID -;; The merge coins each create an announcement of 0 (equivalent to announcing their coin ID) -;; The aggregator asserts that there is a 0 announcement from each of the merge coins - -;; merge coin announces 0 <-> aggregator asserts that merge coin ID announces 0 -;; aggregator announces merge coin ID <-> merge coin asserts that aggregator announces my_id - -(mod - ( - my_id - my_puzhash - my_amount - list_of_parent_puzhash_amounts ; list of (parent_id puzhash amount) for the merge - output_parent_amount ; (parent_id amount) of the coin creating the output - ) - - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include *standard-cl-21*) - - (defun cons_announcements_to_output (coin_id output) - (c - (list ASSERT_COIN_ANNOUNCEMENT (sha256 coin_id 0)) - (c - (list CREATE_COIN_ANNOUNCEMENT coin_id) - output - ) - ) - ) - - (defun for_parent_puzhash_amounts - ( - my_puzhash - (@ coin_info_list ((@ first (parent puzhash amount)) . rest)) - total - ) - (if coin_info_list - (cons_announcements_to_output - (calculate_coin_id parent puzhash amount) - (for_parent_puzhash_amounts my_puzhash rest (+ total amount)) - ) - (list - (list ASSERT_HEIGHT_RELATIVE 5) ; TODO: should this be higher or lower? - (list CREATE_COIN my_puzhash total (list my_puzhash)) - ) - ) - ) - - (defun-inline give_self_to_merge (my_id my_puzhash (@ output_info (parent amount))) - ;; Coins being merged are asserting the output coin id, and insisting it has the same puzhash as them - ;; This ensures that the puzzle which issues the CREATE_COIN condition is the same as this puzzle. - (list - (list CREATE_COIN_ANNOUNCEMENT 0) - (list ASSERT_COIN_ANNOUNCEMENT (sha256 (calculate_coin_id parent my_puzhash amount) my_id)) - ) - ) - - - - (c - (list ASSERT_MY_AMOUNT my_amount) - (c - (list ASSERT_MY_PUZZLEHASH my_puzhash) - (c - (list ASSERT_MY_COIN_ID my_id) - (if list_of_parent_puzhash_amounts - ; we are making the output - (for_parent_puzhash_amounts my_puzhash list_of_parent_puzhash_amounts my_amount) - ; we are letting another coin make the output - (give_self_to_merge my_id my_puzhash output_parent_amount) - ) - ) - ) - ) - -) diff --git a/chia/wallet/puzzles/p2_singleton_aggregator.clsp.hex b/chia/wallet/puzzles/p2_singleton_aggregator.clsp.hex deleted file mode 100644 index 8719fe47a45a..000000000000 --- a/chia/wallet/puzzles/p2_singleton_aggregator.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ffff0149ffff04ff17ffff01808080ffff04ffff04ffff0148ffff04ff0bffff01808080ffff04ffff04ffff0146ffff04ff05ffff01808080ffff02ffff03ff2fffff01ff02ffff01ff02ff0effff04ff02ffff04ff0bffff04ff2fffff04ff17ff808080808080ff0180ffff01ff02ffff01ff04ffff04ffff013cffff04ffff0180ffff01808080ffff04ffff04ffff013dffff04ffff0bffff02ff04ffff04ff02ffff04ffff05ff5f80ffff04ff0bffff04ffff05ffff06ff5f8080ff808080808080ff0580ffff01808080ffff01808080ff018080ff0180808080ffff04ffff01ffff02ffff03ffff22ffff09ffff0dff0580ffff012080ffff09ffff0dff0b80ffff012080ffff15ff17ffff0181ff8080ffff01ff02ffff01ff0bff05ff0bff1780ff0180ffff01ff02ffff01ff0880ff018080ff0180ffff04ffff04ffff013dffff04ffff0bff05ff8080ff808080ffff04ffff04ffff013cffff04ff05ff808080ff0b8080ff02ffff03ff0bffff01ff02ffff01ff02ff0affff04ff02ffff04ffff02ff04ffff04ff02ffff04ff23ffff04ff53ffff04ff8200b3ff808080808080ffff04ffff02ff0effff04ff02ffff04ff05ffff04ff1bffff04ffff10ff17ff8200b380ff808080808080ff8080808080ff0180ffff01ff02ffff01ff04ffff04ffff0152ffff04ffff0105ffff01808080ffff04ffff04ffff0133ffff04ff05ffff04ff17ffff04ffff04ff05ffff018080ffff018080808080ffff01808080ff018080ff0180ff018080 diff --git a/chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp b/chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp deleted file mode 100644 index 016ca7e2ca33..000000000000 --- a/chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp +++ /dev/null @@ -1,50 +0,0 @@ -(mod (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH SECONDS_DELAY DELAYED_PUZZLE_HASH p1 my_id) - - ;; This puzzle has two escape conditions: the regular "claim via singleton", and the - ;; delayed "claim via puzzle hash", delayed by a fixed number of seconds. - - ; SINGLETON_MOD_HASH is the mod-hash for the singleton_top_layer puzzle - ; LAUNCHER_ID is the ID of the singleton we are committed to paying to - ; LAUNCHER_PUZZLE_HASH is the puzzle hash of the launcher - ; SECONDS_DELAY is the number of seconds before the coin can be spent with `DELAYED_PUZZLE_HASH` - ; DELAYED_PUZZLE_HASH is the puzzle hash of the delayed puzzle - ; if my_id is passed in as () then this signals that we are trying to do a delayed spend case - ; p1's meaning changes depending upon which case we're using - ; if we are paying to singleton then p1 is singleton_inner_puzzle_hash - ; if we are running the delayed case then p1 is the amount to output - - (include condition_codes.clib) - (include curry-and-treehash.clib) - - ;; return the full puzzlehash for a singleton with the innerpuzzle curried in - ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib - (defun-inline delayed_spend (SECONDS_DELAY DELAYED_PUZZLE_HASH amount) - (list - (list ASSERT_SECONDS_RELATIVE SECONDS_DELAY) - (list CREATE_COIN DELAYED_PUZZLE_HASH amount) - (list ASSERT_MY_AMOUNT amount) - ) - ) - - ;; return the full puzzlehash for a singleton with the innerpuzzle curried in - ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib - (defun-inline calculate_full_puzzle_hash (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH inner_puzzle_hash) - (puzzle-hash-of-curried-function SINGLETON_MOD_HASH - inner_puzzle_hash - (sha256tree (c SINGLETON_MOD_HASH (c LAUNCHER_ID LAUNCHER_PUZZLE_HASH))) - ) - ) - - (defun-inline claim_rewards (SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash my_id) - (list - (list ASSERT_PUZZLE_ANNOUNCEMENT (sha256 (calculate_full_puzzle_hash SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH singleton_inner_puzzle_hash) my_id)) - (list CREATE_COIN_ANNOUNCEMENT '$') - (list ASSERT_MY_COIN_ID my_id)) - ) - - ; main - (if my_id - (claim_rewards SINGLETON_MOD_HASH LAUNCHER_ID LAUNCHER_PUZZLE_HASH p1 my_id) - (delayed_spend SECONDS_DELAY DELAYED_PUZZLE_HASH p1) - ) -) diff --git a/chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp.hex b/chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp.hex deleted file mode 100644 index 7aacfc51216e..000000000000 --- a/chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff82017fffff01ff04ffff04ff38ffff04ffff0bffff02ff2effff04ff02ffff04ff05ffff04ff81bfffff04ffff02ff3effff04ff02ffff04ffff04ff05ffff04ff0bff178080ff80808080ff808080808080ff82017f80ff808080ffff04ffff04ff3cffff01ff248080ffff04ffff04ff28ffff04ff82017fff808080ff80808080ffff01ff04ffff04ff24ffff04ff2fff808080ffff04ffff04ff2cffff04ff5fffff04ff81bfff80808080ffff04ffff04ff10ffff04ff81bfff808080ff8080808080ff0180ffff04ffff01ffffff49ff463fffff5002ff333cffff04ff0101ffff02ff02ffff03ff05ffff01ff02ff36ffff04ff02ffff04ff0dffff04ffff0bff26ffff0bff2aff1280ffff0bff26ffff0bff26ffff0bff2aff3a80ff0980ffff0bff26ff0bffff0bff2aff8080808080ff8080808080ffff010b80ff0180ffff0bff26ffff0bff2aff3480ffff0bff26ffff0bff26ffff0bff2aff3a80ff0580ffff0bff26ffff02ff36ffff04ff02ffff04ff07ffff04ffff0bff2aff2a80ff8080808080ffff0bff2aff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp b/chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp deleted file mode 100644 index 8403b74efe02..000000000000 --- a/chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp +++ /dev/null @@ -1,47 +0,0 @@ -;; This puzzle holds an amount which can be spent via two spend paths: -;; 1. to a delegated puzzle provided our owner singleton creates a puzzle announcement of this coin's id and the delegated puzzle. -;; 2. coins of this puzzle type can be merged together without the owner singleton's permission. This spend type is useful for DAOs which use this puzzle to custody funds and want to keep a reasonable limit on the number of coins tracked by DAO wallets. -;; The AGGREGATOR_PUZZLE is curried in to preserve generality and so its logic can be updated without requiring any change to the spend to delegated path. Optionally the Aggregator puzzle can be `(x)` to close off this spend path - -(mod ( - SINGLETON_STRUCT - AGGREGATOR_PUZZLE - aggregator_solution ; (my_id my_puzhash list_of_parent_puzhash_amounts my_amount) - singleton_inner_puzhash - delegated_puzzle - delegated_solution - my_id - ) - - (include condition_codes.clib) - (include curry-and-treehash.clib) - - (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT singleton_inner_puzhash) - (puzzle-hash-of-curried-function (f SINGLETON_STRUCT) - singleton_inner_puzhash - (sha256tree SINGLETON_STRUCT) - ) - ) - - (if aggregator_solution - ; we are merging coins to make a larger coin - (a AGGREGATOR_PUZZLE aggregator_solution) - ; we are being spent by our singleton - (c - (list - ASSERT_PUZZLE_ANNOUNCEMENT - (sha256 - (calculate_full_puzzle_hash SINGLETON_STRUCT singleton_inner_puzhash) - (sha256tree (list my_id (sha256tree delegated_puzzle))) - ) - ) - (c - (list CREATE_COIN_ANNOUNCEMENT '$') - (c - (list ASSERT_MY_COIN_ID my_id) - (a delegated_puzzle delegated_solution) - ) - ) - ) - ) -) diff --git a/chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp.hex b/chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp.hex deleted file mode 100644 index 40d51fd27f0c..000000000000 --- a/chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff17ffff01ff02ff0bff1780ffff01ff04ffff04ff18ffff04ffff0bffff02ff2effff04ff02ffff04ff09ffff04ff2fffff04ffff02ff3effff04ff02ffff04ff05ff80808080ff808080808080ffff02ff3effff04ff02ffff04ffff04ff82017fffff04ffff02ff3effff04ff02ffff04ff5fff80808080ff808080ff8080808080ff808080ffff04ffff04ff2cffff01ff248080ffff04ffff04ff10ffff04ff82017fff808080ffff02ff5fff81bf8080808080ff0180ffff04ffff01ffffff463fff02ff3c04ffff01ff0102ffff02ffff03ff05ffff01ff02ff16ffff04ff02ffff04ff0dffff04ffff0bff3affff0bff12ff3c80ffff0bff3affff0bff3affff0bff12ff2a80ff0980ffff0bff3aff0bffff0bff12ff8080808080ff8080808080ffff010b80ff0180ffff0bff3affff0bff12ff1480ffff0bff3affff0bff3affff0bff12ff2a80ff0580ffff0bff3affff02ff16ffff04ff02ffff04ff07ffff04ffff0bff12ff1280ff8080808080ffff0bff12ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/settlement_payments.clsp b/chia/wallet/puzzles/settlement_payments.clsp deleted file mode 100644 index 7feda885a341..000000000000 --- a/chia/wallet/puzzles/settlement_payments.clsp +++ /dev/null @@ -1,49 +0,0 @@ -(mod notarized_payments - ;; `notarized_payments` is a list of notarized coin payments - ;; a notarized coin payment is `(nonce . ((puzzle_hash amount ...) (puzzle_hash amount ...) ...))` - ;; Each notarized coin payment creates some `(CREATE_COIN puzzle_hash amount ...)` payments - ;; and a `(CREATE_PUZZLE_ANNOUNCEMENT (sha256tree notarized_coin_payment))` announcement - ;; The idea is the other side of this trade requires observing the announcement from a - ;; `settlement_payments` puzzle hash as a condition of one or more coin spends. - - (include condition_codes.clib) - (include utility_macros.clib) - - (defun sha256tree (TREE) - (if (l TREE) - (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE))) - (sha256 1 TREE) - ) - ) - - (defun create_coins_for_payment (payment_params so_far) - (if payment_params - (assert (> (f (r (f payment_params))) 0) ; assert the amount is positive - ; then - (c (c CREATE_COIN (f payment_params)) (create_coins_for_payment (r payment_params) so_far)) - ) - so_far - ) - ) - - (defun-inline create_announcement_for_payment (notarized_payment) - (list CREATE_PUZZLE_ANNOUNCEMENT - (sha256tree notarized_payment)) - ) - - (defun-inline augment_condition_list (notarized_payment so_far) - (c - (create_announcement_for_payment notarized_payment) - (create_coins_for_payment (r notarized_payment) so_far) - ) - ) - - (defun construct_condition_list (notarized_payments) - (if notarized_payments - (augment_condition_list (f notarized_payments) (construct_condition_list (r notarized_payments))) - () - ) - ) - - (construct_condition_list notarized_payments) -) diff --git a/chia/wallet/puzzles/settlement_payments.clsp.hex b/chia/wallet/puzzles/settlement_payments.clsp.hex deleted file mode 100644 index cdc88c59fcd0..000000000000 --- a/chia/wallet/puzzles/settlement_payments.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ff0affff04ff02ffff04ff03ff80808080ffff04ffff01ffff333effff02ffff03ff05ffff01ff04ffff04ff0cffff04ffff02ff1effff04ff02ffff04ff09ff80808080ff808080ffff02ff16ffff04ff02ffff04ff19ffff04ffff02ff0affff04ff02ffff04ff0dff80808080ff808080808080ff8080ff0180ffff02ffff03ff05ffff01ff02ffff03ffff15ff29ff8080ffff01ff04ffff04ff08ff0980ffff02ff16ffff04ff02ffff04ff0dffff04ff0bff808080808080ffff01ff088080ff0180ffff010b80ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/sha256tree.clib b/chia/wallet/puzzles/sha256tree.clib deleted file mode 100644 index c374eb3e1d83..000000000000 --- a/chia/wallet/puzzles/sha256tree.clib +++ /dev/null @@ -1,11 +0,0 @@ -( - ;; hash a tree - ;; This is used to calculate a puzzle hash given a puzzle program. - (defun sha256tree - (TREE) - (if (l TREE) - (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE))) - (sha256 1 TREE) - ) - ) -) diff --git a/chia/wallet/puzzles/singleton_launcher.clsp b/chia/wallet/puzzles/singleton_launcher.clsp deleted file mode 100644 index 80d66651ec57..000000000000 --- a/chia/wallet/puzzles/singleton_launcher.clsp +++ /dev/null @@ -1,16 +0,0 @@ -(mod (singleton_full_puzzle_hash amount key_value_list) - - (include condition_codes.clib) - - ; takes a lisp tree and returns the hash of it - (defun sha256tree1 (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE) - ) - ) - - ; main - (list (list CREATE_COIN singleton_full_puzzle_hash amount) - (list CREATE_COIN_ANNOUNCEMENT (sha256tree1 (list singleton_full_puzzle_hash amount key_value_list)))) -) diff --git a/chia/wallet/puzzles/singleton_launcher.clsp.hex b/chia/wallet/puzzles/singleton_launcher.clsp.hex deleted file mode 100644 index 2495bb3d0faa..000000000000 --- a/chia/wallet/puzzles/singleton_launcher.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff04ffff04ff05ffff04ff0bff80808080ffff04ffff04ff0affff04ffff02ff0effff04ff02ffff04ffff04ff05ffff04ff0bffff04ff17ff80808080ff80808080ff808080ff808080ffff04ffff01ff33ff3cff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ff09ff80808080ffff02ff0effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/puzzles/singleton_top_layer.clsp b/chia/wallet/puzzles/singleton_top_layer.clsp deleted file mode 100644 index 21b38f276b17..000000000000 --- a/chia/wallet/puzzles/singleton_top_layer.clsp +++ /dev/null @@ -1,177 +0,0 @@ -(mod (SINGLETON_STRUCT INNER_PUZZLE lineage_proof my_amount inner_solution) - - ;; SINGLETON_STRUCT = (MOD_HASH . (LAUNCHER_ID . LAUNCHER_PUZZLE_HASH)) - - ; SINGLETON_STRUCT, INNER_PUZZLE are curried in by the wallet - - ; EXAMPLE SOLUTION '(0xfadeddab 0xdeadbeef 1 (0xdeadbeef 200) 50 ((51 0xfadeddab 100) (60 "trash") (51 deadbeef 0)))' - - - ; This puzzle is a wrapper around an inner smart puzzle which guarantees uniqueness. - ; It takes its singleton identity from a coin with a launcher puzzle which guarantees that it is unique. - - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include singleton_truths.clib) - - ; takes a lisp tree and returns the hash of it - (defun sha256tree1 (TREE) - (if (l TREE) - (sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE))) - (sha256 1 TREE) - ) - ) - - ; "assert" is a macro that wraps repeated instances of "if" - ; usage: (assert A0 A1 ... An R) - ; all of A0, A1, ... An must evaluate to non-null, or an exception is raised - ; return the value of R (if we get that far) - - (defmacro assert items - (if (r items) - (list if (f items) (c assert (r items)) (q . (x))) - (f items) - ) - ) - - (defun-inline mod_hash_for_singleton_struct (SINGLETON_STRUCT) (f SINGLETON_STRUCT)) - (defun-inline launcher_id_for_singleton_struct (SINGLETON_STRUCT) (f (r SINGLETON_STRUCT))) - (defun-inline launcher_puzzle_hash_for_singleton_struct (SINGLETON_STRUCT) (r (r SINGLETON_STRUCT))) - - ;; return the full puzzlehash for a singleton with the innerpuzzle curried in - ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib - (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (mod_hash_for_singleton_struct SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree1 SINGLETON_STRUCT) - ) - ) - - ; assembles information from the solution to create our own full ID including asserting our parent is a singleton - (defun create_my_ID (SINGLETON_STRUCT full_puzzle_hash parent_parent parent_inner_puzzle_hash parent_amount my_amount) - (sha256 (sha256 parent_parent (calculate_full_puzzle_hash SINGLETON_STRUCT parent_inner_puzzle_hash) parent_amount) - full_puzzle_hash - my_amount) - ) - - ;; take a boolean and a non-empty list of conditions - ;; strip off the first condition if a boolean is set - ;; this is used to remove `(CREATE_COIN xxx -113)` - ;; pretty sneaky, eh? - (defun strip_first_condition_if (boolean condition_list) - (if boolean - (r condition_list) - condition_list - ) - ) - - (defun-inline morph_condition (condition SINGLETON_STRUCT) - (list (f condition) (calculate_full_puzzle_hash SINGLETON_STRUCT (f (r condition))) (f (r (r condition)))) - ) - - ;; return the value of the coin created if this is a `CREATE_COIN` condition, or 0 otherwise - (defun-inline created_coin_value_or_0 (condition) - (if (= (f condition) CREATE_COIN) - (f (r (r condition))) - 0 - ) - ) - - ;; Returns a (bool . bool) - (defun odd_cons_m113 (output_amount) - (c - (= (logand output_amount 1) 1) ;; is it odd? - (= output_amount -113) ;; is it the escape value? - ) - ) - - ; Assert exactly one output with odd value exists - ignore it if value is -113 - - ;; this function iterates over the output conditions from the inner puzzle & solution - ;; and both checks that exactly one unique singleton child is created (with odd valued output), - ;; and wraps the inner puzzle with this same singleton wrapper puzzle - ;; - ;; The special case where the output value is -113 means a child singleton is intentionally - ;; *NOT* being created, thus forever ending this singleton's existence - - (defun check_and_morph_conditions_for_singleton (SINGLETON_STRUCT conditions has_odd_output_been_found) - (if conditions - (morph_next_condition SINGLETON_STRUCT conditions has_odd_output_been_found (odd_cons_m113 (created_coin_value_or_0 (f conditions)))) - (if has_odd_output_been_found - 0 - (x) ;; no odd output found - ) - ) - ) - - ;; a continuation of `check_and_morph_conditions_for_singleton` with booleans `is_output_odd` and `is_output_m113` - ;; precalculated - (defun morph_next_condition (SINGLETON_STRUCT conditions has_odd_output_been_found (is_output_odd . is_output_m113)) - (assert - (not (all is_output_odd has_odd_output_been_found)) - (strip_first_condition_if - is_output_m113 - (c (if is_output_odd - (morph_condition (f conditions) SINGLETON_STRUCT) - (f conditions) - ) - (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (r conditions) (any is_output_odd has_odd_output_been_found)) - ) - ) - ) - ) - - ; this final stager asserts our ID - ; it also runs the innerpuz with the innersolution with the "truths" added - ; it then passes that output conditions from the innerpuz to the morph conditions function - (defun stager_three (SINGLETON_STRUCT lineage_proof my_id full_puzhash innerpuzhash my_amount INNER_PUZZLE inner_solution) - (c (list ASSERT_MY_COIN_ID my_id) (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (a INNER_PUZZLE (c (truth_data_to_truth_struct my_id full_puzhash innerpuzhash my_amount lineage_proof SINGLETON_STRUCT) inner_solution)) 0)) - ) - - ; this checks whether we are an eve spend or not and calculates our full coin ID appropriately and passes it on to the final stager - ; if we are the eve spend it also adds the additional checks that our parent's puzzle is the standard launcher format and that out parent ID is the same as our singleton ID - - (defun stager_two (SINGLETON_STRUCT lineage_proof full_puzhash innerpuzhash my_amount INNER_PUZZLE inner_solution) - (stager_three - SINGLETON_STRUCT - lineage_proof - (if (is_not_eve_proof lineage_proof) - (create_my_ID - SINGLETON_STRUCT - full_puzhash - (parent_info_for_lineage_proof lineage_proof) - (puzzle_hash_for_lineage_proof lineage_proof) - (amount_for_lineage_proof lineage_proof) - my_amount - ) - (if (= - (launcher_id_for_singleton_struct SINGLETON_STRUCT) - (sha256 (parent_info_for_eve_proof lineage_proof) (launcher_puzzle_hash_for_singleton_struct SINGLETON_STRUCT) (amount_for_eve_proof lineage_proof)) - ) - (sha256 (launcher_id_for_singleton_struct SINGLETON_STRUCT) full_puzhash my_amount) - (x) - ) - ) - full_puzhash - innerpuzhash - my_amount - INNER_PUZZLE - inner_solution - ) - ) - - ; this calculates our current full puzzle hash and passes it to stager two - (defun stager_one (SINGLETON_STRUCT lineage_proof my_innerpuzhash my_amount INNER_PUZZLE inner_solution) - (stager_two SINGLETON_STRUCT lineage_proof (calculate_full_puzzle_hash SINGLETON_STRUCT my_innerpuzhash) my_innerpuzhash my_amount INNER_PUZZLE inner_solution) - ) - - - ; main - - ; if our value is not an odd amount then we are invalid - ; this calculates my_innerpuzhash and passes all values to stager_one - (if (logand my_amount 1) - (stager_one SINGLETON_STRUCT lineage_proof (sha256tree1 INNER_PUZZLE) my_amount INNER_PUZZLE inner_solution) - (x) - ) -) diff --git a/chia/wallet/puzzles/singleton_top_layer.clsp.hex b/chia/wallet/puzzles/singleton_top_layer.clsp.hex deleted file mode 100644 index 96c405255fca..000000000000 --- a/chia/wallet/puzzles/singleton_top_layer.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ffff18ff2fffff010180ffff01ff02ff36ffff04ff02ffff04ff05ffff04ff17ffff04ffff02ff26ffff04ff02ffff04ff0bff80808080ffff04ff2fffff04ff0bffff04ff5fff808080808080808080ffff01ff088080ff0180ffff04ffff01ffffffff4602ff3304ffff0101ff02ffff02ffff03ff05ffff01ff02ff5cffff04ff02ffff04ff0dffff04ffff0bff2cffff0bff24ff3880ffff0bff2cffff0bff2cffff0bff24ff3480ff0980ffff0bff2cff0bffff0bff24ff8080808080ff8080808080ffff010b80ff0180ff02ffff03ff0bffff01ff02ff32ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ffff02ff2affff04ff02ffff04ffff02ffff03ffff09ff23ff2880ffff0181b3ff8080ff0180ff80808080ff80808080808080ffff01ff02ffff03ff17ff80ffff01ff088080ff018080ff0180ffffffff0bffff0bff17ffff02ff3affff04ff02ffff04ff09ffff04ff2fffff04ffff02ff26ffff04ff02ffff04ff05ff80808080ff808080808080ff5f80ff0bff81bf80ff02ffff03ffff20ffff22ff4fff178080ffff01ff02ff7effff04ff02ffff04ff6fffff04ffff04ffff02ffff03ff4fffff01ff04ff23ffff04ffff02ff3affff04ff02ffff04ff09ffff04ff53ffff04ffff02ff26ffff04ff02ffff04ff05ff80808080ff808080808080ffff04ff81b3ff80808080ffff011380ff0180ffff02ff7cffff04ff02ffff04ff05ffff04ff1bffff04ffff21ff4fff1780ff80808080808080ff8080808080ffff01ff088080ff0180ffff04ffff09ffff18ff05ffff010180ffff010180ffff09ff05ffff01818f8080ff0bff2cffff0bff24ff3080ffff0bff2cffff0bff2cffff0bff24ff3480ff0580ffff0bff2cffff02ff5cffff04ff02ffff04ff07ffff04ffff0bff24ff2480ff8080808080ffff0bff24ff8080808080ffffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff26ffff04ff02ffff04ff09ff80808080ffff02ff26ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ff5effff04ff02ffff04ff05ffff04ff0bffff04ffff02ff3affff04ff02ffff04ff09ffff04ff17ffff04ffff02ff26ffff04ff02ffff04ff05ff80808080ff808080808080ffff04ff17ffff04ff2fffff04ff5fffff04ff81bfff80808080808080808080ffff04ffff04ff20ffff04ff17ff808080ffff02ff7cffff04ff02ffff04ff05ffff04ffff02ff82017fffff04ffff04ffff04ff17ff2f80ffff04ffff04ff5fff81bf80ffff04ff0bff05808080ff8202ff8080ffff01ff80808080808080ffff02ff2effff04ff02ffff04ff05ffff04ff0bffff04ffff02ffff03ff3bffff01ff02ff22ffff04ff02ffff04ff05ffff04ff17ffff04ff13ffff04ff2bffff04ff5bffff04ff5fff808080808080808080ffff01ff02ffff03ffff09ff15ffff0bff13ff1dff2b8080ffff01ff0bff15ff17ff5f80ffff01ff088080ff018080ff0180ffff04ff17ffff04ff2fffff04ff5fffff04ff81bfffff04ff82017fff8080808080808080808080ff02ffff03ff05ffff011bffff010b80ff0180ff018080 diff --git a/chia/wallet/puzzles/singleton_top_layer.py b/chia/wallet/puzzles/singleton_top_layer.py index d1c1752e6190..ead80187a282 100644 --- a/chia/wallet/puzzles/singleton_top_layer.py +++ b/chia/wallet/puzzles/singleton_top_layer.py @@ -3,6 +3,21 @@ from collections.abc import Iterator from typing import Optional +from chia_puzzles_py.programs import ( + P2_SINGLETON, + P2_SINGLETON_HASH, + P2_SINGLETON_OR_DELAYED_PUZHASH, + P2_SINGLETON_OR_DELAYED_PUZHASH_HASH, + SINGLETON_TOP_LAYER, + SINGLETON_TOP_LAYER_HASH, +) +from chia_puzzles_py.programs import ( + SINGLETON_LAUNCHER as SINGLETON_LAUNCHER_BYTES, +) +from chia_puzzles_py.programs import ( + SINGLETON_LAUNCHER_HASH as SINGLETON_LAUNCHER_HASH_BYTES, +) + from chia.types.blockchain_format.coin import Coin from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 @@ -11,14 +26,15 @@ from chia.util.hash import std_hash from chia.util.ints import uint64 from chia.wallet.lineage_proof import LineageProof -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile - -SINGLETON_MOD = load_clvm_maybe_recompile("singleton_top_layer.clsp") -SINGLETON_MOD_HASH = SINGLETON_MOD.get_tree_hash() -P2_SINGLETON_MOD = load_clvm_maybe_recompile("p2_singleton.clsp") -P2_SINGLETON_OR_DELAYED_MOD = load_clvm_maybe_recompile("p2_singleton_or_delayed_puzhash.clsp") -SINGLETON_LAUNCHER = load_clvm_maybe_recompile("singleton_launcher.clsp") -SINGLETON_LAUNCHER_HASH = SINGLETON_LAUNCHER.get_tree_hash() + +SINGLETON_MOD = Program.from_bytes(SINGLETON_TOP_LAYER) +SINGLETON_MOD_HASH = bytes32(SINGLETON_TOP_LAYER_HASH) +P2_SINGLETON_MOD = Program.from_bytes(P2_SINGLETON) +P2_SINGLETON_MOD_HASH = bytes32(P2_SINGLETON_HASH) +P2_SINGLETON_OR_DELAYED_MOD = Program.from_bytes(P2_SINGLETON_OR_DELAYED_PUZHASH) +P2_SINGLETON_OR_DELAYED_MOD_HASH = bytes32(P2_SINGLETON_OR_DELAYED_PUZHASH_HASH) +SINGLETON_LAUNCHER = Program.from_bytes(SINGLETON_LAUNCHER_BYTES) +SINGLETON_LAUNCHER_HASH = bytes32(SINGLETON_LAUNCHER_HASH_BYTES) ESCAPE_VALUE = -113 MELT_CONDITION = [ConditionOpcode.CREATE_COIN, 0, ESCAPE_VALUE] diff --git a/chia/wallet/puzzles/singleton_top_layer_v1_1.clsp b/chia/wallet/puzzles/singleton_top_layer_v1_1.clsp deleted file mode 100644 index 952d583b5ee0..000000000000 --- a/chia/wallet/puzzles/singleton_top_layer_v1_1.clsp +++ /dev/null @@ -1,107 +0,0 @@ -(mod (SINGLETON_STRUCT INNER_PUZZLE lineage_proof my_amount inner_solution) - - ;; SINGLETON_STRUCT = (MOD_HASH . (LAUNCHER_ID . LAUNCHER_PUZZLE_HASH)) - - ; SINGLETON_STRUCT, INNER_PUZZLE are curried in by the wallet - - ; EXAMPLE SOLUTION '(0xfadeddab 0xdeadbeef 1 (0xdeadbeef 200) 50 ((51 0xfadeddab 100) (60 "trash") (51 deadbeef 0)))' - - - ; This puzzle is a wrapper around an inner smart puzzle which guarantees uniqueness. - ; It takes its singleton identity from a coin with a launcher puzzle which guarantees that it is unique. - - (include condition_codes.clib) - (include curry-and-treehash.clib) ; also imports the constant ONE == 1 - (include singleton_truths.clib) - (include utility_macros.clib) - - (defun-inline mod_hash_for_singleton_struct (SINGLETON_STRUCT) (f SINGLETON_STRUCT)) - (defun-inline launcher_id_for_singleton_struct (SINGLETON_STRUCT) (f (r SINGLETON_STRUCT))) - (defun-inline launcher_puzzle_hash_for_singleton_struct (SINGLETON_STRUCT) (r (r SINGLETON_STRUCT))) - - ;; return the full puzzlehash for a singleton with the innerpuzzle curried in - ; puzzle-hash-of-curried-function is imported from curry-and-treehash.clib - (defun-inline calculate_full_puzzle_hash (SINGLETON_STRUCT inner_puzzle_hash) - (puzzle-hash-of-curried-function (mod_hash_for_singleton_struct SINGLETON_STRUCT) - inner_puzzle_hash - (sha256tree SINGLETON_STRUCT) - ) - ) - - (defun-inline morph_condition (condition SINGLETON_STRUCT) - (c (f condition) (c (calculate_full_puzzle_hash SINGLETON_STRUCT (f (r condition))) (r (r condition)))) - ) - - (defun is_odd_create_coin (condition) - (and (= (f condition) CREATE_COIN) (logand (f (r (r condition))) 1)) - ) - - ; Assert exactly one output with odd value exists - ignore it if value is -113 - - ;; this function iterates over the output conditions from the inner puzzle & solution - ;; and both checks that exactly one unique singleton child is created (with odd valued output), - ;; and wraps the inner puzzle with this same singleton wrapper puzzle - ;; - ;; The special case where the output value is -113 means a child singleton is intentionally - ;; *NOT* being created, thus forever ending this singleton's existence - - (defun check_and_morph_conditions_for_singleton (SINGLETON_STRUCT conditions has_odd_output_been_found) - (if conditions - ; check if it's an odd create coin - (if (is_odd_create_coin (f conditions)) - ; check that we haven't already found one - (assert (not has_odd_output_been_found) - ; then - (if (= (f (r (r (f conditions)))) -113) - ; If it's the melt condition we don't bother prepending this condition - (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (r conditions) ONE) - ; If it isn't the melt condition, we morph it and prepend it - (c (morph_condition (f conditions) SINGLETON_STRUCT) (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (r conditions) ONE)) - ) - ) - (c (f conditions) (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (r conditions) has_odd_output_been_found)) - ) - (assert has_odd_output_been_found ()) - ) - ) - - ; assert that either the lineage proof is for a parent singleton, or, if it's for the launcher, verify it matched our launcher ID - ; then return a condition asserting it actually is our parent ID - (defun verify_lineage_proof (SINGLETON_STRUCT parent_id is_not_launcher) - (assert (any is_not_launcher (= parent_id (launcher_id_for_singleton_struct SINGLETON_STRUCT))) - ; then - (list ASSERT_MY_PARENT_ID parent_id) - ) - ) - - ; main - - ; if our value is not an odd amount then we are invalid - (assert (logand my_amount ONE) - ; then - (c - (list ASSERT_MY_AMOUNT my_amount) - (c - ; Verify the lineage proof by asserting our parent's ID - (verify_lineage_proof - SINGLETON_STRUCT - ; calculate our parent's ID - (calculate_coin_id - (parent_info_for_lineage_proof lineage_proof) - (if (is_not_eve_proof lineage_proof) ; The PH calculation changes based on the lineage proof - (calculate_full_puzzle_hash SINGLETON_STRUCT (puzzle_hash_for_lineage_proof lineage_proof)) ; wrap the innerpuz in a singleton - (launcher_puzzle_hash_for_singleton_struct SINGLETON_STRUCT) ; Use the static launcher puzzle hash - ) - (if (is_not_eve_proof lineage_proof) ; The position of "amount" changes based on the type on lineage proof - (amount_for_lineage_proof lineage_proof) - (amount_for_eve_proof lineage_proof) - ) - ) - (is_not_eve_proof lineage_proof) - ) - ; finally check all of the conditions for a single odd output to wrap - (check_and_morph_conditions_for_singleton SINGLETON_STRUCT (a INNER_PUZZLE inner_solution) 0) - ) - ) - ) -) diff --git a/chia/wallet/puzzles/singleton_top_layer_v1_1.clsp.hex b/chia/wallet/puzzles/singleton_top_layer_v1_1.clsp.hex deleted file mode 100644 index d23ef7c38f8a..000000000000 --- a/chia/wallet/puzzles/singleton_top_layer_v1_1.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ffff18ff2fff3480ffff01ff04ffff04ff20ffff04ff2fff808080ffff04ffff02ff3effff04ff02ffff04ff05ffff04ffff02ff2affff04ff02ffff04ff27ffff04ffff02ffff03ff77ffff01ff02ff36ffff04ff02ffff04ff09ffff04ff57ffff04ffff02ff2effff04ff02ffff04ff05ff80808080ff808080808080ffff011d80ff0180ffff04ffff02ffff03ff77ffff0181b7ffff015780ff0180ff808080808080ffff04ff77ff808080808080ffff02ff3affff04ff02ffff04ff05ffff04ffff02ff0bff5f80ffff01ff8080808080808080ffff01ff088080ff0180ffff04ffff01ffffffff4947ff0233ffff0401ff0102ffffff20ff02ffff03ff05ffff01ff02ff32ffff04ff02ffff04ff0dffff04ffff0bff3cffff0bff34ff2480ffff0bff3cffff0bff3cffff0bff34ff2c80ff0980ffff0bff3cff0bffff0bff34ff8080808080ff8080808080ffff010b80ff0180ffff02ffff03ffff22ffff09ffff0dff0580ff2280ffff09ffff0dff0b80ff2280ffff15ff17ffff0181ff8080ffff01ff0bff05ff0bff1780ffff01ff088080ff0180ff02ffff03ff0bffff01ff02ffff03ffff02ff26ffff04ff02ffff04ff13ff80808080ffff01ff02ffff03ffff20ff1780ffff01ff02ffff03ffff09ff81b3ffff01818f80ffff01ff02ff3affff04ff02ffff04ff05ffff04ff1bffff04ff34ff808080808080ffff01ff04ffff04ff23ffff04ffff02ff36ffff04ff02ffff04ff09ffff04ff53ffff04ffff02ff2effff04ff02ffff04ff05ff80808080ff808080808080ff738080ffff02ff3affff04ff02ffff04ff05ffff04ff1bffff04ff34ff8080808080808080ff0180ffff01ff088080ff0180ffff01ff04ff13ffff02ff3affff04ff02ffff04ff05ffff04ff1bffff04ff17ff8080808080808080ff0180ffff01ff02ffff03ff17ff80ffff01ff088080ff018080ff0180ffffff02ffff03ffff09ff09ff3880ffff01ff02ffff03ffff18ff2dffff010180ffff01ff0101ff8080ff0180ff8080ff0180ff0bff3cffff0bff34ff2880ffff0bff3cffff0bff3cffff0bff34ff2c80ff0580ffff0bff3cffff02ff32ffff04ff02ffff04ff07ffff04ffff0bff34ff3480ff8080808080ffff0bff34ff8080808080ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff2effff04ff02ffff04ff09ff80808080ffff02ff2effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ffff21ff17ffff09ff0bff158080ffff01ff04ff30ffff04ff0bff808080ffff01ff088080ff0180ff018080 diff --git a/chia/wallet/puzzles/singleton_top_layer_v1_1.py b/chia/wallet/puzzles/singleton_top_layer_v1_1.py index bdf9c845a560..7d64b7706a44 100644 --- a/chia/wallet/puzzles/singleton_top_layer_v1_1.py +++ b/chia/wallet/puzzles/singleton_top_layer_v1_1.py @@ -3,6 +3,19 @@ from collections.abc import Iterator from typing import Optional +from chia_puzzles_py.programs import ( + P2_SINGLETON, + P2_SINGLETON_OR_DELAYED_PUZHASH, + SINGLETON_TOP_LAYER_V1_1, + SINGLETON_TOP_LAYER_V1_1_HASH, +) +from chia_puzzles_py.programs import ( + SINGLETON_LAUNCHER as SINGLETON_LAUNCHER_BYTES, +) +from chia_puzzles_py.programs import ( + SINGLETON_LAUNCHER_HASH as SINGLETON_LAUNCHER_HASH_BYTES, +) + from chia.types.blockchain_format.coin import Coin from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 @@ -11,15 +24,14 @@ from chia.util.hash import std_hash from chia.util.ints import uint64 from chia.wallet.lineage_proof import LineageProof -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.uncurried_puzzle import UncurriedPuzzle -SINGLETON_MOD = load_clvm_maybe_recompile("singleton_top_layer_v1_1.clsp") -SINGLETON_MOD_HASH = SINGLETON_MOD.get_tree_hash() -P2_SINGLETON_MOD = load_clvm_maybe_recompile("p2_singleton.clsp") -P2_SINGLETON_OR_DELAYED_MOD = load_clvm_maybe_recompile("p2_singleton_or_delayed_puzhash.clsp") -SINGLETON_LAUNCHER = load_clvm_maybe_recompile("singleton_launcher.clsp") -SINGLETON_LAUNCHER_HASH = SINGLETON_LAUNCHER.get_tree_hash() +SINGLETON_MOD = Program.from_bytes(SINGLETON_TOP_LAYER_V1_1) +SINGLETON_MOD_HASH = bytes32(SINGLETON_TOP_LAYER_V1_1_HASH) +P2_SINGLETON_MOD = Program.from_bytes(P2_SINGLETON) +P2_SINGLETON_OR_DELAYED_MOD = Program.from_bytes(P2_SINGLETON_OR_DELAYED_PUZHASH) +SINGLETON_LAUNCHER = Program.from_bytes(SINGLETON_LAUNCHER_BYTES) +SINGLETON_LAUNCHER_HASH = bytes32(SINGLETON_LAUNCHER_HASH_BYTES) ESCAPE_VALUE = -113 MELT_CONDITION = [ConditionOpcode.CREATE_COIN, 0, ESCAPE_VALUE] diff --git a/chia/wallet/puzzles/singleton_truths.clib b/chia/wallet/puzzles/singleton_truths.clib deleted file mode 100644 index 3c5efc7fa89f..000000000000 --- a/chia/wallet/puzzles/singleton_truths.clib +++ /dev/null @@ -1,21 +0,0 @@ -( - (defun-inline truth_data_to_truth_struct (my_id full_puzhash innerpuzhash my_amount lineage_proof singleton_struct) (c (c my_id full_puzhash) (c (c innerpuzhash my_amount) (c lineage_proof singleton_struct)))) - - (defun-inline my_id_truth (Truths) (f (f Truths))) - (defun-inline my_full_puzzle_hash_truth (Truths) (r (f Truths))) - (defun-inline my_inner_puzzle_hash_truth (Truths) (f (f (r Truths)))) - (defun-inline my_amount_truth (Truths) (r (f (r Truths)))) - (defun-inline my_lineage_proof_truth (Truths) (f (r (r Truths)))) - (defun-inline singleton_struct_truth (Truths) (r (r (r Truths)))) - - (defun-inline singleton_mod_hash_truth (Truths) (f (singleton_struct_truth Truths))) - (defun-inline singleton_launcher_id_truth (Truths) (f (r (singleton_struct_truth Truths)))) - (defun-inline singleton_launcher_puzzle_hash_truth (Truths) (f (r (r (singleton_struct_truth Truths))))) - - (defun-inline parent_info_for_lineage_proof (lineage_proof) (f lineage_proof)) - (defun-inline puzzle_hash_for_lineage_proof (lineage_proof) (f (r lineage_proof))) - (defun-inline amount_for_lineage_proof (lineage_proof) (f (r (r lineage_proof)))) - (defun-inline is_not_eve_proof (lineage_proof) (r (r lineage_proof))) - (defun-inline parent_info_for_eve_proof (lineage_proof) (f lineage_proof)) - (defun-inline amount_for_eve_proof (lineage_proof) (f (r lineage_proof))) -) diff --git a/chia/wallet/puzzles/tails.py b/chia/wallet/puzzles/tails.py index 95a74d3fee28..0b70a9632fe4 100644 --- a/chia/wallet/puzzles/tails.py +++ b/chia/wallet/puzzles/tails.py @@ -2,6 +2,13 @@ from typing import Any, Optional +from chia_puzzles_py.programs import ( + DELEGATED_TAIL, + EVERYTHING_WITH_SIGNATURE, + GENESIS_BY_COIN_ID, + GENESIS_BY_COIN_ID_OR_SINGLETON, + GENESIS_BY_PUZZLE_HASH, +) from chia_rs import Coin from chia.types.blockchain_format.program import Program @@ -19,26 +26,19 @@ from chia.wallet.dao_wallet.dao_utils import create_cat_launcher_for_singleton_id from chia.wallet.lineage_proof import LineageProof from chia.wallet.payment import Payment -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.transaction_record import TransactionRecord from chia.wallet.wallet_action_scope import WalletActionScope from chia.wallet.wallet_spend_bundle import WalletSpendBundle -GENESIS_BY_ID_MOD = load_clvm_maybe_recompile( - "genesis_by_coin_id.clsp", package_or_requirement="chia.wallet.cat_wallet.puzzles" -) -GENESIS_BY_PUZHASH_MOD = load_clvm_maybe_recompile( - "genesis_by_puzzle_hash.clsp", package_or_requirement="chia.wallet.cat_wallet.puzzles" -) -EVERYTHING_WITH_SIG_MOD = load_clvm_maybe_recompile( - "everything_with_signature.clsp", package_or_requirement="chia.wallet.cat_wallet.puzzles" -) -DELEGATED_LIMITATIONS_MOD = load_clvm_maybe_recompile( - "delegated_tail.clsp", package_or_requirement="chia.wallet.cat_wallet.puzzles" -) -GENESIS_BY_ID_OR_SINGLETON_MOD = load_clvm_maybe_recompile( - "genesis_by_coin_id_or_singleton.clsp", package_or_requirement="chia.wallet.cat_wallet.puzzles" -) +GENESIS_BY_ID_MOD = Program.from_bytes(GENESIS_BY_COIN_ID) + +GENESIS_BY_PUZHASH_MOD = Program.from_bytes(GENESIS_BY_PUZZLE_HASH) + +EVERYTHING_WITH_SIG_MOD = Program.from_bytes(EVERYTHING_WITH_SIGNATURE) + +DELEGATED_LIMITATIONS_MOD = Program.from_bytes(DELEGATED_TAIL) + +GENESIS_BY_ID_OR_SINGLETON_MOD = Program.from_bytes(GENESIS_BY_COIN_ID_OR_SINGLETON) class LimitationsProgram: diff --git a/chia/wallet/singleton.py b/chia/wallet/singleton.py index 95fa2966936f..a353039ea2df 100644 --- a/chia/wallet/singleton.py +++ b/chia/wallet/singleton.py @@ -2,12 +2,18 @@ from typing import Optional, Union +from chia_puzzles_py.programs import ( + SINGLETON_LAUNCHER, + SINGLETON_LAUNCHER_HASH, + SINGLETON_TOP_LAYER_V1_1, + SINGLETON_TOP_LAYER_V1_1_HASH, +) + from chia.types.blockchain_format.coin import Coin from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.serialized_program import SerializedProgram from chia.types.blockchain_format.sized_bytes import bytes32 from chia.types.coin_spend import CoinSpend, compute_additions -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.util.curry_and_treehash import ( calculate_hash_of_quoted_mod_hash, curry_and_treehash, @@ -15,12 +21,12 @@ shatree_pair, ) -SINGLETON_TOP_LAYER_MOD = load_clvm_maybe_recompile("singleton_top_layer_v1_1.clsp") -SINGLETON_TOP_LAYER_MOD_HASH = SINGLETON_TOP_LAYER_MOD.get_tree_hash() +SINGLETON_TOP_LAYER_MOD = Program.from_bytes(SINGLETON_TOP_LAYER_V1_1) +SINGLETON_TOP_LAYER_MOD_HASH = bytes32(SINGLETON_TOP_LAYER_V1_1_HASH) SINGLETON_TOP_LAYER_MOD_HASH_TREE_HASH = shatree_atom(SINGLETON_TOP_LAYER_MOD_HASH) SINGLETON_TOP_LAYER_MOD_HASH_QUOTED = calculate_hash_of_quoted_mod_hash(SINGLETON_TOP_LAYER_MOD_HASH) -SINGLETON_LAUNCHER_PUZZLE = load_clvm_maybe_recompile("singleton_launcher.clsp") -SINGLETON_LAUNCHER_PUZZLE_HASH = SINGLETON_LAUNCHER_PUZZLE.get_tree_hash() +SINGLETON_LAUNCHER_PUZZLE = Program.from_bytes(SINGLETON_LAUNCHER) +SINGLETON_LAUNCHER_PUZZLE_HASH = bytes32(SINGLETON_LAUNCHER_HASH) SINGLETON_LAUNCHER_PUZZLE_HASH_TREE_HASH = shatree_atom(SINGLETON_LAUNCHER_PUZZLE_HASH) diff --git a/chia/wallet/trade_manager.py b/chia/wallet/trade_manager.py index 0496732abec9..59acc54bca8d 100644 --- a/chia/wallet/trade_manager.py +++ b/chia/wallet/trade_manager.py @@ -32,7 +32,6 @@ from chia.wallet.outer_puzzles import AssetType from chia.wallet.payment import Payment from chia.wallet.puzzle_drivers import PuzzleInfo, Solver -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.trade_record import TradeRecord from chia.wallet.trading.offer import NotarizedPayment, Offer from chia.wallet.trading.trade_status import TradeStatus @@ -54,8 +53,6 @@ from chia.wallet.wallet_state_manager import WalletStateManager from chia.wallet.wallet_spend_bundle import WalletSpendBundle -OFFER_MOD = load_clvm_maybe_recompile("settlement_payments.clsp") - class TradeManager: """ diff --git a/chia/wallet/trading/offer.py b/chia/wallet/trading/offer.py index 76a0dca8e0aa..28840c8efe23 100644 --- a/chia/wallet/trading/offer.py +++ b/chia/wallet/trading/offer.py @@ -3,6 +3,7 @@ from dataclasses import dataclass, field from typing import Any, BinaryIO, Optional, Union +from chia_puzzles_py.programs import SETTLEMENT_PAYMENT, SETTLEMENT_PAYMENT_HASH from chia_rs import G2Element from clvm_tools.binutils import disassemble @@ -33,7 +34,6 @@ ) from chia.wallet.payment import Payment from chia.wallet.puzzle_drivers import PuzzleInfo, Solver -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.uncurried_puzzle import UncurriedPuzzle, uncurry_puzzle from chia.wallet.util.compute_hints import compute_spend_hints_and_additions from chia.wallet.util.puzzle_compression import ( @@ -43,8 +43,8 @@ ) from chia.wallet.wallet_spend_bundle import WalletSpendBundle -OFFER_MOD = load_clvm_maybe_recompile("settlement_payments.clsp") -OFFER_MOD_HASH = OFFER_MOD.get_tree_hash() +OFFER_MOD = Program.from_bytes(SETTLEMENT_PAYMENT) +OFFER_MOD_HASH = bytes32(SETTLEMENT_PAYMENT_HASH) def detect_dependent_coin( diff --git a/chia/wallet/util/notifications.py b/chia/wallet/util/notifications.py index 8a6fb16f58d6..472ddfd7ac8d 100644 --- a/chia/wallet/util/notifications.py +++ b/chia/wallet/util/notifications.py @@ -1,11 +1,12 @@ from __future__ import annotations +from chia_puzzles_py.programs import NOTIFICATION + from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 from chia.util.ints import uint64 -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile -NOTIFICATION_MOD = load_clvm_maybe_recompile("notification.clsp") +NOTIFICATION_MOD = Program.from_bytes(NOTIFICATION) def construct_notification(target: bytes32, amount: uint64) -> Program: diff --git a/chia/wallet/util/puzzle_compression.py b/chia/wallet/util/puzzle_compression.py index 316a88965c6c..8d42fdc8534f 100644 --- a/chia/wallet/util/puzzle_compression.py +++ b/chia/wallet/util/puzzle_compression.py @@ -2,6 +2,8 @@ import zlib +from chia_puzzles_py.programs import SETTLEMENT_PAYMENT + from chia.types.blockchain_format.program import Program from chia.wallet.cat_wallet.cat_utils import CAT_MOD from chia.wallet.nft_wallet.nft_puzzles import ( @@ -9,10 +11,11 @@ NFT_OWNERSHIP_LAYER, NFT_STATE_LAYER_MOD, NFT_TRANSFER_PROGRAM_DEFAULT, - SINGLETON_TOP_LAYER_MOD, ) from chia.wallet.puzzles import p2_delegated_puzzle_or_hidden_puzzle as standard_puzzle -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile +from chia.wallet.singleton import ( + SINGLETON_TOP_LAYER_MOD, +) # Need the legacy CAT mod for zlib backwards compatibility LEGACY_CAT_MOD = Program.fromhex( @@ -22,7 +25,6 @@ OFFER_MOD_OLD = Program.fromhex( "ff02ffff01ff02ff0affff04ff02ffff04ff03ff80808080ffff04ffff01ffff333effff02ffff03ff05ffff01ff04ffff04ff0cffff04ffff02ff1effff04ff02ffff04ff09ff80808080ff808080ffff02ff16ffff04ff02ffff04ff19ffff04ffff02ff0affff04ff02ffff04ff0dff80808080ff808080808080ff8080ff0180ffff02ffff03ff05ffff01ff04ffff04ff08ff0980ffff02ff16ffff04ff02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080" ) -OFFER_MOD = load_clvm_maybe_recompile("settlement_payments.clsp") # For backwards compatibility to work, we must assume that these mods (already deployed) will not change # In the case that they do change and we don't support the old asset then we need to keep around the legacy module @@ -35,7 +37,7 @@ + bytes(NFT_METADATA_UPDATER) + bytes(NFT_TRANSFER_PROGRAM_DEFAULT), bytes(CAT_MOD), - bytes(OFFER_MOD), + SETTLEMENT_PAYMENT, b"", # purposefully break compatibility with older versions # more dictionaries go here ] diff --git a/chia/wallet/vc_wallet/cr_cat_drivers.py b/chia/wallet/vc_wallet/cr_cat_drivers.py index 55988447f715..54fafe44fdb9 100644 --- a/chia/wallet/vc_wallet/cr_cat_drivers.py +++ b/chia/wallet/vc_wallet/cr_cat_drivers.py @@ -6,6 +6,16 @@ from enum import IntEnum from typing import Optional, TypeVar +from chia_puzzles_py.programs import ( + CONDITIONS_W_FEE_ANNOUNCE, + FLAG_PROOFS_CHECKER, +) +from chia_puzzles_py.programs import ( + CREDENTIAL_RESTRICTION as CREDENTIAL_RESTRICTION_BYTES, +) +from chia_puzzles_py.programs import ( + CREDENTIAL_RESTRICTION_HASH as CREDENTIAL_RESTRICTION_HASH_BYTES, +) from clvm.casts import int_to_bytes from chia.types.blockchain_format.coin import Coin, coin_as_list @@ -19,7 +29,6 @@ from chia.wallet.conditions import AssertCoinAnnouncement from chia.wallet.lineage_proof import LineageProof, LineageProofField from chia.wallet.payment import Payment -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.puzzles.singleton_top_layer_v1_1 import SINGLETON_LAUNCHER_HASH, SINGLETON_MOD_HASH from chia.wallet.uncurried_puzzle import UncurriedPuzzle, uncurry_puzzle from chia.wallet.util.curry_and_treehash import curry_and_treehash @@ -35,22 +44,10 @@ # Mods -CREDENTIAL_RESTRICTION: Program = load_clvm_maybe_recompile( - "credential_restriction.clsp", - package_or_requirement="chia.wallet.vc_wallet.cr_puzzles", - include_standard_libraries=True, -) -CREDENTIAL_RESTRICTION_HASH: bytes32 = CREDENTIAL_RESTRICTION.get_tree_hash() -PROOF_FLAGS_CHECKER: Program = load_clvm_maybe_recompile( - "flag_proofs_checker.clsp", - package_or_requirement="chia.wallet.vc_wallet.cr_puzzles", - include_standard_libraries=True, -) -PENDING_VC_ANNOUNCEMENT: Program = load_clvm_maybe_recompile( - "conditions_w_fee_announce.clsp", - package_or_requirement="chia.wallet.vc_wallet.cr_puzzles", - include_standard_libraries=True, -) +CREDENTIAL_RESTRICTION: Program = Program.from_bytes(CREDENTIAL_RESTRICTION_BYTES) +CREDENTIAL_RESTRICTION_HASH: bytes32 = bytes32(CREDENTIAL_RESTRICTION_HASH_BYTES) +PROOF_FLAGS_CHECKER: Program = Program.from_bytes(FLAG_PROOFS_CHECKER) +PENDING_VC_ANNOUNCEMENT: Program = Program.from_bytes(CONDITIONS_W_FEE_ANNOUNCE) CREDENTIAL_STRUCT: Program = Program.to( ( ( diff --git a/chia/wallet/vc_wallet/cr_puzzles/__init__.py b/chia/wallet/vc_wallet/cr_puzzles/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp b/chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp deleted file mode 100644 index 52c1db45a8d1..000000000000 --- a/chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp +++ /dev/null @@ -1,3 +0,0 @@ -(mod (CONDITIONS nonce) - (c (list 60 nonce) CONDITIONS) -) diff --git a/chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp.hex b/chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp.hex deleted file mode 100644 index 32d91e137ad1..000000000000 --- a/chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff04ffff04ffff013cffff04ff05ff808080ff0280 diff --git a/chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp b/chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp deleted file mode 100644 index 326829946692..000000000000 --- a/chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp +++ /dev/null @@ -1,304 +0,0 @@ -; This is an outer puzzle for a coin that imposes a restriction that the coin can only be spent with an -; announcement from a "verified credential" whose proofs are present due to a DID in a list of authorized providers. - -; A "verified credential" is defined as the following puzzle stack: -; - singleton top layer -; |_exigent metadata layer -; |_eml transfer program covenant adapter -; | |_covenant layer -; | |_initial puzzle (hashed) -; | | |_singleton top layer -; | | |_exigent metadata layer -; | | |_(mod (_ _ (provider tp)) (list (c provider ()) tp ())) (guaranteed metadata to be nil) -; | | |_p2 announced delegated puzzle -; | |_eml covenant morpher -; | |_eml update metadata with DID -; |_ -; The information to construct a VC is contained in a highly optimized way within CREDENTIAL_STRUCT -; -; This puzzle does many things: -; - Tree hash of a partially revealed tree to come to a proof hash present in the accompanying VC singleton -; - Validate the revealed proofs with a curried proofs checker -; - Assert an announcement from a VC with a message of 0xca which signals this spend is ok -; - Wrap all of its children in this layer -; - Create an announcement in the 0xcd namespace of each output it is creating (for a VC to assert if it wishes) -; - Block any announcements coming from the inner puzzle in the 0xcd namespace -(mod - ( - ; We curry twice: first, all of the static information we need, then the hash of the program with all of that info - ; this allows use to be more efficient when calculating our own hash (a (q . SELF_HASH) (c SELF_HASH (x INNER_PUZZLE 1))) - ; curried first - CREDENTIAL_STRUCT - AUTHORIZED_PROVIDERS - PROOFS_CHECKER - ; curried second - SELF_HASH - INNER_PUZZLE - proof_of_inclusions ; Proof that key/value pairs exist in a tree (the root of the tree is implicit from this) - proof_checker_solution ; solution to PROOFS_CHECKER program - provider_id ; the DID that is curried into the metadata of the VC that is authorizing this coin - credential_id ; the launcher ID of the VC that is authorizing this coin - credential_inner_puzhash ; The (see above) of the VC that is authorizing this coin - my_coin_id ; This coin's ID - inner_solution - ) - - (include curry.clib) - (include condition_codes.clib) - (include utility_macros.clib) - - ; take two lists and merge them into one - (defun merge_list (list_a list_b) - (if list_a - (c (f list_a) (merge_list (r list_a) list_b)) - list_b - ) - ) - - (defconstant announcement_namespace 0xcd) - (defconstant ONE 1) - - (defun-inline wrap_puzhash - ( - SELF_HASH - puzhash - ) - - (curry_hashes SELF_HASH - (sha256 ONE SELF_HASH) - puzhash - ) - ) - - ; Does three things: - ; 1) Wraps create coins with this layer - ; 2) Announces those create coins in a namespace - ; 3) Raises on announcements from the inner puzzle that could possibly be in the namespace - (defun process_conditions - ( - SELF_HASH - conditions - ) - (if conditions - (if (= (f (f conditions)) CREATE_COIN) - (c - (list - CREATE_COIN_ANNOUNCEMENT - (concat - announcement_namespace - (sha256 (f (r (f conditions))) (f (r (r (f conditions))))) - ) - ) - (c - (c - CREATE_COIN - (c - (wrap_puzhash SELF_HASH (f (r (f conditions)))) - (r (r (f conditions))) - ) - ) - (process_conditions SELF_HASH (r conditions)) - ) - ) - ; else - not a create coin - (assert (or - (not (= (f (f conditions)) CREATE_COIN_ANNOUNCEMENT)) ; some coin announcements should be blocked - (not (= 33 (strlen (f (r (f conditions)))))) ; we only care about blocking 0xcd + some_hash - (not (= announcement_namespace (substr (f (r (f conditions))) 0 ONE))) ; block prefix 0xcd - ) - ; then - (c - (f conditions) - (process_conditions SELF_HASH (r conditions)) - ) - ) - ) - ; else - end of list - () - ) - ) - - (defun create_vc_puzhash_stage_2 - ( - ( - ( - ( - SINGLETON_MOD_HASH - . - SINGLETON_LAUNCHER_HASH - ) - . - ( - OWNERSHIP_LAYER_MOD_HASH - . - ADAPTER_MOD_HASH - ) - ) - . - ( - INITIAL_SINGLETON_INNER_PUZHASH - . - ( - TWO_AND_COVENANT_MOD_HASH ; (concat 2 COVENANT_MOD_HASH) - . - REST_COVENANT_ARGS_HASH ; ((c PARENT_MORPHER (c EML_DID_TP 1)) . ()) hashed - ) - ) - ) - provider_id - credential_singleton_struct_hash - proof_hash - credential_inner_puzhash - tp_hash - ) - - (curry_hashes SINGLETON_MOD_HASH - credential_singleton_struct_hash - (curry_hashes OWNERSHIP_LAYER_MOD_HASH - (sha256 ONE OWNERSHIP_LAYER_MOD_HASH) - (sha256 TWO - (sha256 ONE provider_id) - (sha256 ONE proof_hash) - ) - tp_hash - (sha256 ONE tp_hash) - credential_inner_puzhash - ) - ) - ) - - (defun create_vc_puzhash - ( - CREDENTIAL_STRUCT - provider_id - credential_singleton_struct_hash - proof_hash - credential_inner_puzhash - ) - - (create_vc_puzhash_stage_2 - CREDENTIAL_STRUCT - provider_id - credential_singleton_struct_hash - proof_hash - credential_inner_puzhash - (curry_hashes (r (r (f CREDENTIAL_STRUCT))) ; ADAPTER_MOD_HASH - (sha256 - ; apply - (two_sha256_one_a_kw) - (sha256 - ; func - (f (r (r CREDENTIAL_STRUCT))) ; TWO_AND_COVENANT_MOD_HASH - (sha256 TWO - ; args - (sha256 - (two_sha256_one_c_kw) - (sha256 TWO - (sha256 TWO - (sha256_one_one) - (sha256 ONE (curry_hashes (f (f (f CREDENTIAL_STRUCT))) ; SINGLETON_MOD_HASH - credential_singleton_struct_hash - (f (r CREDENTIAL_STRUCT)) ; INITIAL_SINGLETON_INNER_PUZHASH - )) - ) - (r (r (r CREDENTIAL_STRUCT))) ; REST_COVENANT_ARGS_HASH - ) - ) - (sha256_one) - ) - ) - ) - ) - ) - ) - - ; utility function that turns the output of two calls to collapse_tree_and_note_leaf_info into a single return value - (defun branch_hash_and_merge_info ((TREE1 PROOFS1) (TREE2 PROOFS2)) - (list - (sha256 TWO TREE1 TREE2) - (merge_list PROOFS1 PROOFS2) - ) - ) - - (defun collapse_tree_and_note_leaf_info (TREE PROOFS) - (if (l TREE) - (if (or (l (f TREE)) (l (r TREE))) ; If either side is a cons, we have not reached a leaf pair yet - (branch_hash_and_merge_info - (collapse_tree_and_note_leaf_info (f TREE) ()) - ; we favor right because merge_list merges from left - (collapse_tree_and_note_leaf_info (r TREE) PROOFS) - ) - ; else - both first and rest are atoms, we are at a key/value pair - (branch_hash_and_merge_info - (list (sha256 ONE (f TREE)) ()) - (list (sha256 ONE (r TREE)) (c TREE PROOFS)) - ) - ) - (list TREE PROOFS) ; All atoms that we reach must be pre-hashed subtrees - ) - ) - - (defun main - ( - CREDENTIAL_STRUCT - AUTHORIZED_PROVIDERS - PROOFS_CHECKER - SELF_HASH - proof_checker_solution - provider_id - credential_id - credential_inner_puzhash - my_coin_id - conditions - (tree_hash proofs) - ) - - (assert - ; Run proof checker to make sure it doesn't return () (fail) - (a PROOFS_CHECKER (list proofs proof_checker_solution)) - (in provider_id AUTHORIZED_PROVIDERS) ; VC needs to be in authorized list - ; then - (c - (list ASSERT_MY_COIN_ID my_coin_id) - (c - (list ASSERT_PUZZLE_ANNOUNCEMENT - (sha256 - (create_vc_puzhash - CREDENTIAL_STRUCT - provider_id - (sha256 TWO - (sha256 ONE (f (f (f CREDENTIAL_STRUCT)))) ; SINGLETON_MOD_HASH - (sha256 TWO - (sha256 ONE credential_id) - (sha256 ONE (r (f (f CREDENTIAL_STRUCT)))) ; SINGLETON_LAUNCHER_HASH - ) - ) - tree_hash - credential_inner_puzhash - ) - (sha256 my_coin_id 0xca) ; my_coin_id because VC must announce specifically to us - ) - ) - (process_conditions - SELF_HASH - conditions - ) - ) - ) - ) - ) - - (main - CREDENTIAL_STRUCT - AUTHORIZED_PROVIDERS - PROOFS_CHECKER - SELF_HASH - proof_checker_solution - provider_id - credential_id - credential_inner_puzhash - my_coin_id - (a INNER_PUZZLE inner_solution) - (collapse_tree_and_note_leaf_info proof_of_inclusions ()) - ) -) diff --git a/chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp.hex b/chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp.hex deleted file mode 100644 index a163e67c7954..000000000000 --- a/chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ff2effff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff82017fffff04ff8202ffffff04ff8205ffffff04ff820bffffff04ff8217ffffff04ffff02ff5fff822fff80ffff04ffff02ff22ffff04ff02ffff04ff81bfffff01ff8080808080ff8080808080808080808080808080ffff04ffff01ffffffff463fff333cffff0102ff81cdffff04ffff0bff34ff09ff1380ffff04ffff02ff5effff04ff02ffff04ff15ffff04ff2bff8080808080ff808080ff02ffff03ff05ffff01ff0bff81f2ffff02ff26ffff04ff02ffff04ff09ffff04ffff02ff7cffff04ff02ffff04ff0dff80808080ff808080808080ffff0181d280ff0180ffffffff02ffff03ffff07ff0580ffff01ff02ffff03ffff02ffff03ffff07ff0980ffff01ff0101ffff01ff02ffff03ffff07ff0d80ffff01ff0101ff8080ff018080ff0180ffff01ff02ff5cffff04ff02ffff04ffff02ff22ffff04ff02ffff04ff09ffff01ff8080808080ffff04ffff02ff22ffff04ff02ffff04ff0dffff04ff0bff8080808080ff8080808080ffff01ff02ff5cffff04ff02ffff04ffff04ffff0bff24ff0980ffff01ff808080ffff04ffff04ffff0bff24ff0d80ffff04ffff04ff05ff0b80ff808080ff808080808080ff0180ffff01ff04ff05ffff04ff0bff80808080ff0180ffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffff02ff5affff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ffff02ff7affff04ff02ffff04ff39ffff04ffff0bff81b2ffff0bff2dffff0bff34ffff0bff81f2ffff0bff34ffff0bff34ff81d2ffff0bff24ffff02ff7affff04ff02ffff04ff21ffff04ff17ffff04ff15ff8080808080808080ff3d8080ff8192808080ff8080808080ff808080808080808080ffff02ff7affff04ff02ffff04ff21ffff04ff17ffff04ffff02ff7affff04ff02ffff04ff29ffff04ffff0bff24ff2980ffff04ffff0bff34ffff0bff24ff0b80ffff0bff24ff2f8080ffff04ff81bfffff04ffff0bff24ff81bf80ffff04ff5fff808080808080808080ff808080808080ff0bff81b2ffff02ff26ffff04ff02ffff04ff05ffff04ffff02ff7cffff04ff02ffff04ff07ff80808080ff808080808080ffffff0bff34ffff0bff34ff81d2ff0580ffff0bff34ff0bff81928080ff02ffff03ff0bffff01ff03ffff09ff05ff1380ffff0101ffff02ff36ffff04ff02ffff04ff05ffff04ff1bff808080808080ff8080ff0180ffff02ffff03ffff02ff17ffff04ff8257ffffff04ff5fff80808080ffff01ff02ffff03ffff02ff36ffff04ff02ffff04ff81bfffff04ff0bff8080808080ffff01ff04ffff04ff20ffff04ff8205ffff808080ffff04ffff04ff30ffff04ffff0bffff02ff2affff04ff02ffff04ff05ffff04ff81bfffff04ffff0bff34ffff0bff24ff2180ffff0bff34ffff0bff24ff82017f80ffff0bff24ff31808080ffff04ff8227ffffff04ff8202ffff8080808080808080ffff0bff8205ffffff0181ca8080ff808080ffff02ff7effff04ff02ffff04ff2fffff04ff820bffff80808080808080ffff01ff088080ff0180ffff01ff088080ff0180ffff02ffff03ff05ffff01ff04ff09ffff02ff5effff04ff02ffff04ff0dffff04ff0bff808080808080ffff010b80ff0180ff02ffff03ff0bffff01ff02ffff03ffff09ff23ff2880ffff01ff04ffff04ff38ffff04ffff0eff2cffff0bff53ff81b38080ff808080ffff04ffff04ff28ffff04ffff02ff7affff04ff02ffff04ff05ffff04ffff0bff24ff0580ffff04ff53ff808080808080ff738080ffff02ff7effff04ff02ffff04ff05ffff04ff1bff80808080808080ffff01ff02ffff03ffff02ffff03ffff20ffff09ff23ff388080ffff01ff0101ffff01ff02ffff03ffff20ffff09ffff0121ffff0dff53808080ffff01ff0101ffff01ff02ffff03ffff20ffff09ff2cffff0cff53ff80ff24808080ffff01ff0101ff8080ff018080ff018080ff0180ffff01ff04ff13ffff02ff7effff04ff02ffff04ff05ffff04ff1bff808080808080ffff01ff088080ff018080ff0180ff8080ff0180ff018080 diff --git a/chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp b/chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp deleted file mode 100644 index b83f8a8a0def..000000000000 --- a/chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp +++ /dev/null @@ -1,45 +0,0 @@ -; This is a PROOFS_CHECKER for use with credential_restriction.clsp -; -; In an attempt to be as simple as possible, this puzzle is curried a list of key/value pairs sorted by keys. This sort -; is crucial to the program functioning as the key/value pairs of the proofs will be sorted before being compared to -; the curried list. -(mod - ( - FLAGS ; must be sorted - proofs ; will be sorted - solution ; unused - ) - - (include utility_macros.clib) - - (defun insertion_sort_by_keys (sorted insertions) - (if insertions - (if (or (not sorted) (>s (f (f insertions)) (f (f sorted)))) - (insertion_sort_by_keys (c (f insertions) sorted) (r insertions)) - (insertion_sort_by_keys (c (f sorted) (insertion_sort_by_keys (r sorted) (list (f insertions)))) (r insertions)) - ) - sorted - ) - ) - - (defun merge_insertion_sort (proofs) - (if (r proofs) - (insertion_sort_by_keys (merge_insertion_sort (r proofs)) (merge_insertion_sort (list (f proofs)))) - proofs - ) - ) - - ; This function checks that the revealed proofs START WITH the same key/value pairs as are in FLAGS. This is not for - ; any particular reason except optimization. We don't really care if EXTRA proof pairs are revealed. - (defun compare_first_pairs_against_flags (subject comp) - (if subject - (if (logand (= (f (f subject)) (f (f comp))) (= (r (f subject)) (r (f comp)))) - (compare_first_pairs_against_flags (r subject) (r comp)) - () - ) - 1 - ) - ) - - (compare_first_pairs_against_flags FLAGS (merge_insertion_sort proofs)) -) diff --git a/chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp.hex b/chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp.hex deleted file mode 100644 index c0c17d0728a3..000000000000 --- a/chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ff04ffff04ff02ffff04ff05ffff04ffff02ff0effff04ff02ffff04ff0bff80808080ff8080808080ffff04ffff01ffff02ffff03ff05ffff01ff02ffff03ffff18ffff09ff11ff2380ffff09ff19ff338080ffff01ff02ff04ffff04ff02ffff04ff0dffff04ff1bff8080808080ff8080ff0180ffff01ff010180ff0180ffff02ffff03ff0bffff01ff02ffff03ffff02ffff03ffff20ff0580ffff01ff0101ffff01ff02ffff03ffff0aff23ff1180ffff01ff0101ff8080ff018080ff0180ffff01ff02ff0affff04ff02ffff04ffff04ff13ff0580ffff04ff1bff8080808080ffff01ff02ff0affff04ff02ffff04ffff04ff09ffff02ff0affff04ff02ffff04ff0dffff04ffff04ff13ff8080ff808080808080ffff04ff1bff808080808080ff0180ffff010580ff0180ff02ffff03ff0dffff01ff02ff0affff04ff02ffff04ffff02ff0effff04ff02ffff04ff0dff80808080ffff04ffff02ff0effff04ff02ffff04ffff04ff09ff8080ff80808080ff8080808080ffff010580ff0180ff018080 diff --git a/chia/wallet/vc_wallet/vc_drivers.py b/chia/wallet/vc_wallet/vc_drivers.py index 6f71074d1098..ed1cd67f4757 100644 --- a/chia/wallet/vc_wallet/vc_drivers.py +++ b/chia/wallet/vc_wallet/vc_drivers.py @@ -3,6 +3,24 @@ from dataclasses import dataclass, replace from typing import Optional, TypeVar +from chia_puzzles_py.programs import ACS_TRANSFER_PROGRAM as ACS_TRANSFER_PROGRAM_BYTES +from chia_puzzles_py.programs import COVENANT_LAYER as COVENANT_LAYER_BYTES +from chia_puzzles_py.programs import COVENANT_LAYER_HASH as COVENANT_LAYER_HASH_BYTES +from chia_puzzles_py.programs import EML_COVENANT_MORPHER as EML_COVENANT_MORPHER_BYTES +from chia_puzzles_py.programs import EML_COVENANT_MORPHER_HASH as EML_COVENANT_MORPHER_HASH_BYTES +from chia_puzzles_py.programs import EML_TRANSFER_PROGRAM_COVENANT_ADAPTER as EML_TP_COVENANT_ADAPTER_BYTES +from chia_puzzles_py.programs import EML_TRANSFER_PROGRAM_COVENANT_ADAPTER_HASH as EML_TP_COVENANT_ADAPTER_HASH_BYTES +from chia_puzzles_py.programs import EML_UPDATE_METADATA_WITH_DID as EML_DID_TP_BYTES +from chia_puzzles_py.programs import EXIGENT_METADATA_LAYER as EXIGENT_METADATA_LAYER_BYTES +from chia_puzzles_py.programs import EXIGENT_METADATA_LAYER_HASH as EXIGENT_METADATA_LAYER_HASH_BYTES +from chia_puzzles_py.programs import P2_ANNOUNCED_DELEGATED_PUZZLE as P2_ANNOUNCED_DELEGATED_PUZZLE_BYTES +from chia_puzzles_py.programs import P2_ANNOUNCED_DELEGATED_PUZZLE_HASH as P2_ANNOUNCED_DELEGATED_PUZZLE_HASH_BYTES +from chia_puzzles_py.programs import REVOCATION_LAYER as REVOCATION_LAYER_BYTES +from chia_puzzles_py.programs import REVOCATION_LAYER_HASH as REVOCATION_LAYER_HASH_BYTES +from chia_puzzles_py.programs import STANDARD_VC_REVOCATION_PUZZLE as STANDARD_VC_REVOCATION_PUZZLE_BYTES +from chia_puzzles_py.programs import STD_PARENT_MORPHER as STD_PARENT_MORPHER_BYTES +from chia_puzzles_py.programs import STD_PARENT_MORPHER_HASH as STD_PARENT_MORPHER_HASH_BYTES + from chia.types.blockchain_format.coin import Coin from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 @@ -12,7 +30,6 @@ from chia.util.streamable import Streamable, streamable from chia.wallet.conditions import Condition, CreatePuzzleAnnouncement from chia.wallet.lineage_proof import LineageProof -from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile from chia.wallet.puzzles.singleton_top_layer_v1_1 import ( SINGLETON_LAUNCHER, SINGLETON_LAUNCHER_HASH, @@ -25,67 +42,32 @@ from chia.wallet.uncurried_puzzle import UncurriedPuzzle, uncurry_puzzle # Mods -EXTIGENT_METADATA_LAYER = load_clvm_maybe_recompile( - "exigent_metadata_layer.clsp", - package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", - include_standard_libraries=True, -) -P2_ANNOUNCED_DELEGATED_PUZZLE: Program = load_clvm_maybe_recompile( - "p2_announced_delegated_puzzle.clsp", - package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", - include_standard_libraries=True, -) -COVENANT_LAYER: Program = load_clvm_maybe_recompile( - "covenant_layer.clsp", package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", include_standard_libraries=True -) -STD_COVENANT_PARENT_MORPHER: Program = load_clvm_maybe_recompile( - "std_parent_morpher.clsp", - package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", - include_standard_libraries=True, -) -EML_TP_COVENANT_ADAPTER: Program = load_clvm_maybe_recompile( - "eml_transfer_program_covenant_adapter.clsp", - package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", - include_standard_libraries=True, -) -EML_DID_TP: Program = load_clvm_maybe_recompile( - "eml_update_metadata_with_DID.clsp", - package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", - include_standard_libraries=True, -) -EXTIGENT_METADATA_LAYER_COVENANT_MORPHER: Program = load_clvm_maybe_recompile( - "eml_covenant_morpher.clsp", - package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", - include_standard_libraries=True, -) -VIRAL_BACKDOOR: Program = load_clvm_maybe_recompile( - "viral_backdoor.clsp", package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", include_standard_libraries=True -) -# (mod (METADATA conditions . solution) (if solution solution (list METADATA () ()))) -# (a (i 7 (q . 7) (q 4 2 (q () ()))) 1) -ACS_TRANSFER_PROGRAM: Program = Program.to([2, [3, 7, (1, 7), [1, 4, 2, [1, None, None]]], 1]) - +EXTIGENT_METADATA_LAYER = Program.from_bytes(EXIGENT_METADATA_LAYER_BYTES) +P2_ANNOUNCED_DELEGATED_PUZZLE: Program = Program.from_bytes(P2_ANNOUNCED_DELEGATED_PUZZLE_BYTES) +COVENANT_LAYER: Program = Program.from_bytes(COVENANT_LAYER_BYTES) +STD_COVENANT_PARENT_MORPHER: Program = Program.from_bytes(STD_PARENT_MORPHER_BYTES) +EML_TP_COVENANT_ADAPTER: Program = Program.from_bytes(EML_TP_COVENANT_ADAPTER_BYTES) +EML_DID_TP: Program = Program.from_bytes(EML_DID_TP_BYTES) +EXTIGENT_METADATA_LAYER_COVENANT_MORPHER: Program = Program.from_bytes(EML_COVENANT_MORPHER_BYTES) +REVOCATION_LAYER: Program = Program.from_bytes(REVOCATION_LAYER_BYTES) +ACS_TRANSFER_PROGRAM: Program = Program.from_bytes(ACS_TRANSFER_PROGRAM_BYTES) # Hashes -EXTIGENT_METADATA_LAYER_HASH = EXTIGENT_METADATA_LAYER.get_tree_hash() -P2_ANNOUNCED_DELEGATED_PUZZLE_HASH: bytes32 = P2_ANNOUNCED_DELEGATED_PUZZLE.get_tree_hash() -COVENANT_LAYER_HASH: bytes32 = COVENANT_LAYER.get_tree_hash() -STD_COVENANT_PARENT_MORPHER_HASH: bytes32 = STD_COVENANT_PARENT_MORPHER.get_tree_hash() -EML_TP_COVENANT_ADAPTER_HASH: bytes32 = EML_TP_COVENANT_ADAPTER.get_tree_hash() -EXTIGENT_METADATA_LAYER_COVENANT_MORPHER_HASH: bytes32 = EXTIGENT_METADATA_LAYER_COVENANT_MORPHER.get_tree_hash() -VIRAL_BACKDOOR_HASH: bytes32 = VIRAL_BACKDOOR.get_tree_hash() +EXTIGENT_METADATA_LAYER_HASH = bytes32(EXIGENT_METADATA_LAYER_HASH_BYTES) +P2_ANNOUNCED_DELEGATED_PUZZLE_HASH: bytes32 = bytes32(P2_ANNOUNCED_DELEGATED_PUZZLE_HASH_BYTES) +COVENANT_LAYER_HASH: bytes32 = bytes32(COVENANT_LAYER_HASH_BYTES) +STD_COVENANT_PARENT_MORPHER_HASH: bytes32 = bytes32(STD_PARENT_MORPHER_HASH_BYTES) +EML_TP_COVENANT_ADAPTER_HASH: bytes32 = bytes32(EML_TP_COVENANT_ADAPTER_HASH_BYTES) +EXTIGENT_METADATA_LAYER_COVENANT_MORPHER_HASH: bytes32 = bytes32(EML_COVENANT_MORPHER_HASH_BYTES) +REVOCATION_LAYER_HASH: bytes32 = bytes32(REVOCATION_LAYER_HASH_BYTES) # Standard brick puzzle uses the mods above -STANDARD_BRICK_PUZZLE: Program = load_clvm_maybe_recompile( - "standard_vc_backdoor_puzzle.clsp", - package_or_requirement="chia.wallet.vc_wallet.vc_puzzles", - include_standard_libraries=True, -).curry( +STANDARD_BRICK_PUZZLE: Program = Program.from_bytes(STANDARD_VC_REVOCATION_PUZZLE_BYTES).curry( SINGLETON_MOD_HASH, Program.to(SINGLETON_LAUNCHER_HASH).get_tree_hash(), EXTIGENT_METADATA_LAYER_HASH, - VIRAL_BACKDOOR_HASH, + REVOCATION_LAYER_HASH, ACS_TRANSFER_PROGRAM.get_tree_hash(), ) STANDARD_BRICK_PUZZLE_HASH: bytes32 = STANDARD_BRICK_PUZZLE.get_tree_hash() @@ -190,22 +172,22 @@ def solve_did_tp( ############################## # P2 Puzzle or Hidden Puzzle # ############################## -def create_viral_backdoor(hidden_puzzle_hash: bytes32, inner_puzzle_hash: bytes32) -> Program: - return VIRAL_BACKDOOR.curry( - VIRAL_BACKDOOR_HASH, +def create_revocation_layer(hidden_puzzle_hash: bytes32, inner_puzzle_hash: bytes32) -> Program: + return REVOCATION_LAYER.curry( + REVOCATION_LAYER_HASH, hidden_puzzle_hash, inner_puzzle_hash, ) -def match_viral_backdoor(uncurried_puzzle: UncurriedPuzzle) -> Optional[tuple[bytes32, bytes32]]: - if uncurried_puzzle.mod == VIRAL_BACKDOOR: +def match_revocation_layer(uncurried_puzzle: UncurriedPuzzle) -> Optional[tuple[bytes32, bytes32]]: + if uncurried_puzzle.mod == REVOCATION_LAYER: return bytes32(uncurried_puzzle.args.at("rf").as_atom()), bytes32(uncurried_puzzle.args.at("rrf").as_atom()) else: return None # pragma: no cover -def solve_viral_backdoor(puzzle_reveal: Program, inner_solution: Program, hidden: bool = False) -> Program: +def solve_revocation_layer(puzzle_reveal: Program, inner_solution: Program, hidden: bool = False) -> Program: solution: Program = Program.to( [ hidden, @@ -371,7 +353,7 @@ def launch( inner_transfer_program, ) ) - wrapped_inner_puzzle_hash: bytes32 = create_viral_backdoor( + wrapped_inner_puzzle_hash: bytes32 = create_revocation_layer( STANDARD_BRICK_PUZZLE_HASH, new_inner_puzzle_hash, ).get_tree_hash() @@ -485,7 +467,7 @@ def construct_transfer_program(self) -> Program: ) def wrap_inner_with_backdoor(self) -> Program: - return create_viral_backdoor( + return create_revocation_layer( self.hidden_puzzle().get_tree_hash(), self.inner_puzzle_hash, ) @@ -543,7 +525,7 @@ def is_vc(puzzle_reveal: UncurriedPuzzle) -> tuple[bool, str]: # ...and layer below EML layer_below_eml: UncurriedPuzzle = uncurry_puzzle(layer_below_singleton.args.at("rrrrf")) - if layer_below_eml.mod != VIRAL_BACKDOOR: + if layer_below_eml.mod != REVOCATION_LAYER: return False, "VC did not have a provider backdoor" # pragma: no cover hidden_puzzle_hash = bytes32(layer_below_eml.args.at("rf").as_atom()) if hidden_puzzle_hash != STANDARD_BRICK_PUZZLE_HASH: @@ -616,7 +598,7 @@ def get_next_from_coin_spend(cls: type[_T_VerifiedCredential], parent_spend: Coi parent_proof_hash: bytes32 = metadata_layer.args.at("rf").get_tree_hash() eml_lineage_proof = VCLineageProof( parent_name=parent_coin.parent_coin_info, - inner_puzzle_hash=create_viral_backdoor( + inner_puzzle_hash=create_revocation_layer( STANDARD_BRICK_PUZZLE_HASH, bytes32(uncurry_puzzle(metadata_layer.args.at("rrrrf")).args.at("rrf").as_atom()), ).get_tree_hash(), @@ -720,7 +702,7 @@ def do_spend( uint64(self.coin.amount), Program.to( [ # solve EML - solve_viral_backdoor( + solve_revocation_layer( inner_puzzle, inner_solution, ), @@ -773,7 +755,7 @@ def activate_backdoor( uint64(self.coin.amount), Program.to( [ # solve EML - solve_viral_backdoor( + solve_revocation_layer( self.hidden_puzzle(), solve_std_vc_backdoor( self.launcher_id, diff --git a/chia/wallet/vc_wallet/vc_puzzles/__init__.py b/chia/wallet/vc_wallet/vc_puzzles/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp b/chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp deleted file mode 100644 index 855cbe4b1618..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp +++ /dev/null @@ -1,30 +0,0 @@ -; This is a utility layer for a coin that allows it to prove that it came from some INITIAL_PUZZLE_HASH -(mod - ( - INITIAL_PUZZLE_HASH ; The ancestor's puzzle hash this layer is evidence of - PARENT_MORPHER ; Defines how to wrap a parent inner puzzle hash to prove that it had this layer running inside it - INNER_PUZZLE - lineage_proof ; parent id, parent inner puzzle hash (wrapped with PARENT_MORPHER), parent amount - morpher_solution ; solution to PARENT_MORPHER - inner_solution - ) - - (include condition_codes.clib) - - (c - (list ASSERT_MY_PARENT_ID - (sha256 - (f lineage_proof) - (if (r (r lineage_proof)) ; different logic based on whether the lineage proof is 2 or 3 elements long - (a PARENT_MORPHER (c INITIAL_PUZZLE_HASH (c (f (r lineage_proof)) morpher_solution))) - INITIAL_PUZZLE_HASH - ) - (if (r (r lineage_proof)) ; different logic based on whether the lineage proof is 2 or 3 elements long - (f (r (r lineage_proof))) - (f (r lineage_proof)) - ) - ) - ) - (a INNER_PUZZLE inner_solution) - ) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp.hex deleted file mode 100644 index e36547ed21dd..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff02ffff04ffff0bff4fffff02ffff03ff81efffff01ff02ff0bffff04ff05ffff04ff81afff5f808080ffff010580ff0180ffff02ffff03ff81efffff0182016fffff0181af80ff018080ff808080ffff02ff17ff81bf8080ffff04ffff0147ff018080 diff --git a/chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp b/chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp deleted file mode 100644 index ac5fd18dae97..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp +++ /dev/null @@ -1,75 +0,0 @@ -; This is a PARENT_MORPHER for use with covenant_layer.clsp - -; It is used to prove that the parent was a singleton -> exigent metadata layer (w/ covenant_layer in TP) puzzle stack -(mod - ( - ; We curry twice: first, all of the static information we need, then the hash of the program with all of that info - ; this allows use to be more efficient when calculating our own hash (a (q . SELF_HASH) (c SELF_HASH 1)) - ; curried first - a bunch of info to create a singleton -> ownership layer puzzle stack - COVENANT_MOD_HASH - EML_MOD_HASH - ADAPTER_MOD_HASH - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_HASH_HASH - TP_HASH - ; curried second - SELF_HASH ; tree hash of all the other hashes above - ; Truths - COVENANT_INITIAL_PUZZLE_HASH - PREVIOUS_INNER_PUZHASH - ; solution - previous_metadata_hash ; pre-treehashed METADATA from our parent's EML - my_singleton_id ; no need to commit to this, our parent is guaranteed to be a singleton with the same ID as ours - ) - - (include curry.clib) - - (defconstant ONE 1) - - (defun main - ( - EML_MOD_HASH - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_HASH_HASH - PREVIOUS_INNER_PUZHASH - previous_metadata_hash - my_singleton_id - tp_hash - ) - - (curry_hashes SINGLETON_MOD_HASH - (sha256 TWO - (sha256 ONE SINGLETON_MOD_HASH) - (sha256 TWO - (sha256 ONE my_singleton_id) - SINGLETON_LAUNCHER_HASH_HASH - ) - ) - (curry_hashes EML_MOD_HASH - (sha256 ONE EML_MOD_HASH) - previous_metadata_hash - tp_hash - (sha256 ONE tp_hash) - PREVIOUS_INNER_PUZHASH - ) - ) - ) - - (main - EML_MOD_HASH - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_HASH_HASH - PREVIOUS_INNER_PUZHASH - previous_metadata_hash - my_singleton_id - (curry_hashes ADAPTER_MOD_HASH - (curry_hashes COVENANT_MOD_HASH - (sha256 ONE COVENANT_INITIAL_PUZZLE_HASH) - (curry_hashes SELF_HASH - (sha256 ONE SELF_HASH) - ) - TP_HASH - ) - ) - ) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp.hex deleted file mode 100644 index 89fbfc3ada79..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ff1effff04ff02ffff04ff0bffff04ff2fffff04ff5fffff04ff8205ffffff04ff820bffffff04ff8217ffffff04ffff02ff1affff04ff02ffff04ff17ffff04ffff02ff1affff04ff02ffff04ff05ffff04ffff0bff08ff8202ff80ffff04ffff02ff1affff04ff02ffff04ff82017fffff04ffff0bff08ff82017f80ff8080808080ffff04ff81bfff80808080808080ff8080808080ff80808080808080808080ffff04ffff01ffff01ff02ff02ffff03ff05ffff01ff0bff72ffff02ff16ffff04ff02ffff04ff09ffff04ffff02ff1cffff04ff02ffff04ff0dff80808080ff808080808080ffff016280ff0180ffffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff0bff52ffff02ff16ffff04ff02ffff04ff05ffff04ffff02ff1cffff04ff02ffff04ff07ff80808080ff808080808080ffff0bff14ffff0bff14ff62ff0580ffff0bff14ff0bff428080ff02ff1affff04ff02ffff04ff0bffff04ffff0bff14ffff0bff08ff0b80ffff0bff14ffff0bff08ff81bf80ff178080ffff04ffff02ff1affff04ff02ffff04ff05ffff04ffff0bff08ff0580ffff04ff5fffff04ff82017fffff04ffff0bff08ff82017f80ffff04ff2fff808080808080808080ff808080808080ff018080 diff --git a/chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp b/chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp deleted file mode 100644 index 21dbf1d42fa9..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp +++ /dev/null @@ -1,32 +0,0 @@ -; This is a layer that adapts the API between an ownership layer and its transfer program when the transfer program is -; wrapped with a covenant layer. -(mod - ( - COVENANT_LAYER - METADATA ; Truth - CONDITIONS ; Truth - ; covenant layer solution - ( - lineage_proof - morpher_solution - inner_solution - ) - ) - - ; Solution from covenant layer comes back like so: - ; ((ASSERT_MY_PARENT_ID 0x...) new_metadata new_tp conditions) - ; so we need to move that ASSERT_MY_PARENT_ID to the returned conditions from the TP - (defun fix_condition ((parent_assertion . (new_owner new_tp conditions))) - (list new_owner new_tp (c parent_assertion conditions)) - ) - - (fix_condition (a - COVENANT_LAYER - (list - lineage_proof - morpher_solution - ; Covenant layer doesn't know about truths so we need to pass those down to the inner tp solution - (list METADATA CONDITIONS inner_solution) - ) - )) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp.hex deleted file mode 100644 index a521768816f7..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ff02ffff04ff02ffff04ffff02ff05ffff04ff4fffff04ff81afffff04ffff04ff0bffff04ff17ffff04ff82016fff80808080ff8080808080ff80808080ffff04ffff01ff04ff15ffff04ff2dffff04ffff04ff09ff5d80ff80808080ff018080 diff --git a/chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp b/chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp deleted file mode 100644 index 8080ed8cb0c8..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp +++ /dev/null @@ -1,80 +0,0 @@ -; This is a TRANSFER_PROGRAM for use with exigent_metadata_layer.clsp - -; Given a DID's singleton struct, assert its announcement of any changes. If no DID's innerpuz is provided, then just -; return the same metadata and transfer program with no conditions - -; This TP also allows metadata to be cleared and transfer program to be reset simultaneously, no DID required -(mod - ( - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_HASH - (provider_id . metadata) ; Truth - conditions ; Truth - ; tp_solution looks like this in the case of a DID update - ( - provider_innerpuzhash - my_coin_id - new_metadata - new_transfer_program_hash - ) - ; tp_solution could also be () or new_transfer_program_hash for two other cases: - ; - () == continue with the same metadata we currently have - ; - new_transfer_program_hash == update the transfer program to whatever, but clear the metadata - ) - - (include condition_codes.clib) - (include curry.clib) - (include sha256tree.clib) - (include utility_macros.clib) - - (defconstant ONE 1) - - (defun-inline create_did_puzhash - ( - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_HASH - provider_id - provider_innerpuzhash - ) - - (curry_hashes_inline SINGLETON_MOD_HASH - ; calculate the singleton struct - (sha256 TWO - (sha256 ONE SINGLETON_MOD_HASH) - (sha256 TWO - (sha256 ONE provider_id) - (sha256 ONE SINGLETON_LAUNCHER_HASH) - ) - ) - provider_innerpuzhash - ) - ) - - ; Returning (new_metadata new_transfer_program_hash conditions) - (if (l (f (r (r (r (r (r @))))))) ; If a tp solution was provided - (list - (i new_metadata (c provider_id new_metadata) ()) - new_transfer_program_hash - (list - (list ASSERT_MY_COIN_ID my_coin_id) - ; get an announcement from the DID in the EML's metadata to update to a new metadata and transfer program - (list ASSERT_PUZZLE_ANNOUNCEMENT - (sha256 - (create_did_puzhash SINGLETON_MOD_HASH SINGLETON_LAUNCHER_HASH provider_id provider_innerpuzhash) - (sha256 - my_coin_id - (sha256tree new_metadata) - new_transfer_program_hash - ) - ) - ) - ) - ) - ; else - the tp_solution is an atom - (if (f (r (r (r (r (r @)))))) ; If a new_transfer_program_hash was provided - (list () (f (r (r (r (r (r @)))))) ()) - ; else - No new TP was provided, continue with current metadata - (list (c provider_id metadata) () ()) - ) - ) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp.hex deleted file mode 100644 index 737d28ed403c..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ffff07ff5f80ffff01ff04ffff03ff8202dfffff04ff27ff8202df80ff8080ffff04ff8205dfffff04ffff04ffff04ff08ffff04ff82015fff808080ffff04ffff04ff14ffff04ffff0bffff0bff56ffff0bff0affff0bff0aff66ff0580ffff0bff0affff0bff76ffff0bff0affff0bff0aff66ffff0bff0affff0bff1cff0580ffff0bff0affff0bff1cff2780ffff0bff1cff0b80808080ffff0bff0affff0bff76ffff0bff0affff0bff0aff66ff819f80ffff0bff0aff66ff46808080ff46808080ff46808080ffff0bff82015fffff02ff1effff04ff02ffff04ff8202dfff80808080ff8205df8080ff808080ff808080ff80808080ffff01ff02ffff03ff5fffff01ff04ff80ffff04ff5fffff01ff80808080ffff01ff04ffff04ff27ff3780ffff01ff80ff80808080ff018080ff0180ffff04ffff01ffff46ff3f01ff02ffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff1effff04ff02ffff04ff09ff80808080ffff02ff1effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp b/chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp deleted file mode 100644 index a50b97db1928..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp +++ /dev/null @@ -1,163 +0,0 @@ -; This layer is an outer puzzle that keeps some metadata that must be reaffirmed by a "transfer program" on every spend. -; -; In a way, this puzzle acts as a p2_merkle_tree puzzle where there are always two leaves and BOTH must run every spend. -; -; The inner puzzle runs first and actually supplies the solution to the transfer program. -; -; Likely, the transfer program is placed into the EML by a party who does not currently control the coin, to enforce -; that certain behaviors regarding the curried metadata are followed. -(mod - ( - THIS_MOD_HASH - METADATA ; The metadata can be anything. It is passed to the transfer program and new metadata is returned. - TRANSFER_PROGRAM ; Runs every spend, solution supplied by the inner puzzle - TRANSFER_PROGRAM_HASH ; we also include the hash for efficiency's sake when re-calculating our own hash - INNER_PUZZLE - inner_solution - ) - - (include condition_codes.clib) - (include curry-and-treehash.clib) - (include utility_macros.clib) - - (defun-inline nft_ownership_layer_puzzle_hash - ( - THIS_MOD_HASH - new_owner - TRANSFER_PROGRAM_HASH - inner_puzzle_hash - ) - (puzzle-hash-of-curried-function THIS_MOD_HASH - inner_puzzle_hash - (sha256 ONE TRANSFER_PROGRAM_HASH) - TRANSFER_PROGRAM_HASH - (sha256tree new_owner) - (sha256 ONE THIS_MOD_HASH) - ) - ) - - (defun-inline construct_end_conditions - ( - THIS_MOD_HASH - TRANSFER_PROGRAM - TRANSFER_PROGRAM_HASH - odd_args - (new_owner new_tp_hash conditions) - ) - (c - (c - CREATE_COIN - (c - (nft_ownership_layer_puzzle_hash - THIS_MOD_HASH - new_owner - (if new_tp_hash new_tp_hash TRANSFER_PROGRAM_HASH) - (f odd_args) - ) - (r odd_args) - ) - ) - conditions - ) - ) - - (defun process_conditions - ( - THIS_MOD_HASH - TRANSFER_PROGRAM - TRANSFER_PROGRAM_HASH - METADATA - all_conditions - conditions - ; These args all start at () - ( - odd_args - tp_output - condition_to_prepend - ) - ) - ; This loop works a bit differently than most condition wrapping loops - ; - ; We expect an invalid condition (-10) that we must strip out, but we must also wrap the odd create coin based on - ; information from that condition. - ; - ; To facilitate this, each iteration of the loop calls the next iteration with the condition it wishes to prepend - ; to the list. If we want to strip out a condition, we call the next iteration with () as condition_to_prepend - ; which will cause an empty REMARK condition to be prepended as a no-op instead. The two conditions that will - ; trigger this are the magic condition (-10) and the odd create coin condition. The magic condition never makes it - ; back into the list, but the CREATE_COIN is re-created wrapped by construct_end_conditions. - (c - (i condition_to_prepend condition_to_prepend (list REMARK)) - (if conditions - (process_conditions - THIS_MOD_HASH - TRANSFER_PROGRAM - TRANSFER_PROGRAM_HASH - METADATA - all_conditions - (r conditions) - (if (= (f (f conditions)) CREATE_COIN) - (if (logand (f (r (r (f conditions)))) 1) - (assert (not odd_args) - ; then - (list (r (f conditions)) tp_output ()) - ) - ; else - amount is not odd - (list odd_args tp_output (f conditions)) - ) - ; else - condition is not a create coin - (if (= (f (f conditions)) -10) ; -10 is "magic" opcode for running transfer program - (assert (not tp_output) - ; then - (list - odd_args - (a TRANSFER_PROGRAM (list METADATA all_conditions (r (f conditions)))) - () - ) - ) - ; else - condition is not a create coin nor a NEW_OWNER_CONDITION - (list odd_args tp_output (f conditions)) - ) - ) - ) - ; else - we have no more conditions - ; odd_args and tp_solution are guaranteed to not be nil or else we'll have a path into atom error - (construct_end_conditions - THIS_MOD_HASH - TRANSFER_PROGRAM - TRANSFER_PROGRAM_HASH - odd_args - tp_output - ) - ) - ) - ) - - (defun main - ( - THIS_MOD_HASH - TRANSFER_PROGRAM - TRANSFER_PROGRAM_HASH - METADATA - conditions - ) - (process_conditions - THIS_MOD_HASH - TRANSFER_PROGRAM - TRANSFER_PROGRAM_HASH - METADATA - conditions - conditions - (list () () ()) - ) - ) - - ; main - (main - THIS_MOD_HASH - TRANSFER_PROGRAM - TRANSFER_PROGRAM_HASH - METADATA - (a INNER_PUZZLE inner_solution) - ) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp.hex deleted file mode 100644 index c21e51a42b5d..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ff3affff04ff02ffff04ff05ffff04ff17ffff04ff2fffff04ff0bffff04ffff02ff5fff81bf80ff8080808080808080ffff04ffff01ffffff02ff3304ff01ff0101ffff02ffff02ffff03ff05ffff01ff02ff2affff04ff02ffff04ff0dffff04ffff0bff12ffff0bff14ff3880ffff0bff12ffff0bff12ffff0bff14ff2c80ff0980ffff0bff12ff0bffff0bff14ff8080808080ff8080808080ffff010b80ff0180ff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff5fffff01ffff80ff80ff8080808080808080808080ffff04ffff03ff820b7fff820b7fffff04ff3cff808080ffff02ffff03ff81bfffff01ff02ff16ffff04ff02ffff04ff05ffff04ff0bffff04ff17ffff04ff2fffff04ff5fffff04ff8201bfffff04ffff02ffff03ffff09ff82023fff2880ffff01ff02ffff03ffff18ff820b3fffff010180ffff01ff02ffff03ffff20ff82027f80ffff01ff04ff82033fffff04ff82057fffff01ff80808080ffff01ff088080ff0180ffff01ff04ff82027fffff04ff82057fffff04ff82013fff8080808080ff0180ffff01ff02ffff03ffff09ff82023fffff0181f680ffff01ff02ffff03ffff20ff82057f80ffff01ff04ff82027fffff04ffff02ff0bffff04ff2fffff04ff5fffff04ff82033fff8080808080ffff01ff80808080ffff01ff088080ff0180ffff01ff04ff82027fffff04ff82057fffff04ff82013fff8080808080ff018080ff0180ff80808080808080808080ffff01ff04ffff04ff28ffff04ffff02ff2effff04ff02ffff04ff05ffff04ff82047fffff04ffff0bff14ffff02ffff03ff82157fffff0182157fffff011780ff018080ffff04ffff02ffff03ff82157fffff0182157fffff011780ff0180ffff04ffff02ff3effff04ff02ffff04ff82097fff80808080ffff04ffff0bff14ff0580ff808080808080808080ff82067f8080ff822d7f8080ff018080ffff0bff12ffff0bff14ff1080ffff0bff12ffff0bff12ffff0bff14ff2c80ff0580ffff0bff12ffff02ff2affff04ff02ffff04ff07ffff04ffff0bff14ff1480ff8080808080ffff0bff14ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff3effff04ff02ffff04ff09ff80808080ffff02ff3effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp b/chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp deleted file mode 100644 index 93a32017272f..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp +++ /dev/null @@ -1,16 +0,0 @@ -; This is a generalization of the idea behind singleton_launcher.clsp - -; Given a delegated puzzle and solution, just run them and announce the hash of the delegated puzzle. -; A parent can rely on this announcement so if the exact delegated_puzzle it is expecting is not run, the whole bundle -; fails due to a grandparent paradox. -(mod - ( - delegated_puzzle - delegated_solution - ) - - (include condition_codes.clib) - (include sha256tree.clib) - - (c (list CREATE_COIN_ANNOUNCEMENT (sha256tree delegated_puzzle)) (a delegated_puzzle delegated_solution)) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp.hex deleted file mode 100644 index 93a7130af31d..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff04ffff04ffff02ff06ffff04ff02ffff04ff05ff80808080ff808080ffff02ff05ff0b8080ffff04ffff01ff3cff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 diff --git a/chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp b/chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp deleted file mode 100644 index 46e47355598b..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp +++ /dev/null @@ -1,74 +0,0 @@ -; This is the standard puzzle that a VerifiedCredential provider will put into the backdoor slot of viral_backdoor.clsp - -; The goal of this puzzle is to recreate the VC exactly as it is except for three things: -; 1) There is no longer a viral backdoor layer -; 2) The metadata in the ownership layer becomes () -; 3) The transfer program in the ownership layer becomes a curried default -(mod - ( - SINGLETON_MOD_HASH - SINGLETON_LAUNCHER_HASH_HASH - OWNERSHIP_LAYER_MOD_HASH - VIRAL_BACKDOOR_MOD_HASH - DEFAULT_TRANSFER_PROGRAM_HASH - ; most of the specific information is solved rather than curried in because we don't care about committing to it - launcher_id ; of the singleton this is inside of - metadata_hash ; of the EML this is inside of - tp_hash ; of the EML this is inside of - this_hash_hash ; the hash of this puzzle with all of its curried arguments hashed AGAIN with (sha256 1 this_hash) - inner_puzzle_hash ; that determines ownership of this coin - my_amount ; this coin's amount - ownership_lineage_proof ; need to solve the covenant layer one last time - previous_metadata_hash ; like metadata_hash above but for the previous coin - announcement_nonce ; Anything to announce (for fees/DID to hook onto) - ( - provider_innerpuzhash ; DID needs to authorize the transfer program (and therefore this backdoor) - my_coin_id - ) - ) - - (include condition_codes.clib) - (include curry.clib) - - (defconstant ONE 1) - - (list - ; The purpose of this condition is just to make sure we're telling the truth about the current inner puzzle hash - (list ASSERT_MY_PUZZLEHASH - (curry_hashes SINGLETON_MOD_HASH - (sha256 TWO - (sha256 ONE SINGLETON_MOD_HASH) - (sha256 TWO - (sha256 ONE launcher_id) - SINGLETON_LAUNCHER_HASH_HASH - ) - ) - (curry_hashes OWNERSHIP_LAYER_MOD_HASH - (sha256 ONE OWNERSHIP_LAYER_MOD_HASH) - metadata_hash - tp_hash - (sha256 ONE tp_hash) - (curry_hashes VIRAL_BACKDOOR_MOD_HASH - (sha256 ONE VIRAL_BACKDOOR_MOD_HASH) - this_hash_hash - (sha256 ONE inner_puzzle_hash) - ) - ) - ) - ) - (list ASSERT_MY_AMOUNT my_amount) - (list CREATE_COIN inner_puzzle_hash my_amount) - (list CREATE_COIN_ANNOUNCEMENT announcement_nonce) ; For fee hooks - (list - -10 - ownership_lineage_proof ; for covenant layer - (list previous_metadata_hash launcher_id) ; for covenant layer parent morpher - (list ; for transfer program - provider_innerpuzhash - my_coin_id - () - DEFAULT_TRANSFER_PROGRAM_HASH - ) - ) - ) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp.hex deleted file mode 100644 index 9375a0edd051..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff04ffff04ff18ffff04ffff02ff2effff04ff02ffff04ff05ffff04ffff0bff12ffff0bff3cff0580ffff0bff12ffff0bff3cff81bf80ff0b8080ffff04ffff02ff2effff04ff02ffff04ff17ffff04ffff0bff3cff1780ffff04ff82017fffff04ff8202ffffff04ffff0bff3cff8202ff80ffff04ffff02ff2effff04ff02ffff04ff2fffff04ffff0bff3cff2f80ffff04ff8205ffffff04ffff0bff3cff820bff80ff80808080808080ff808080808080808080ff808080808080ff808080ffff04ffff04ff10ffff04ff8217ffff808080ffff04ffff04ff14ffff04ff820bffffff04ff8217ffff80808080ffff04ffff04ff2cffff04ff82bfffff808080ffff04ffff04ffff0181f6ffff04ff822fffffff04ffff04ff825fffffff04ff81bfff808080ffff04ffff04ff83027fffffff04ff83057fffffff04ff80ffff04ff5fff8080808080ff8080808080ff808080808080ffff04ffff01ffffff4948ff33ff3c01ffff02ff02ffff03ff05ffff01ff0bff76ffff02ff3effff04ff02ffff04ff09ffff04ffff02ff1affff04ff02ffff04ff0dff80808080ff808080808080ffff016680ff0180ffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffff0bff56ffff02ff3effff04ff02ffff04ff05ffff04ffff02ff1affff04ff02ffff04ff07ff80808080ff808080808080ff0bff12ffff0bff12ff66ff0580ffff0bff12ff0bff468080ff018080 diff --git a/chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp b/chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp deleted file mode 100644 index 4c20273a54e0..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp +++ /dev/null @@ -1,23 +0,0 @@ -; This is a PARENT_MORPHER for use with covenant_layer.clsp - -; You would use this morpher when the covenant layer is the outermost layer of the coin -(mod - ( - THIS_MOD_HASH - COVENANT_MOD_HASH - COVENANT_INITIAL_PUZZLE_HASH - inner_puzhash - ) - - (include curry.clib) - - (curry_hashes_inline COVENANT_MOD_HASH - (sha256 1 COVENANT_INITIAL_PUZZLE_HASH) - (curry_hashes_inline THIS_MOD_HASH - (sha256 1 THIS_MOD_HASH) - (sha256 1 COVENANT_MOD_HASH) - (sha256 1 COVENANT_INITIAL_PUZZLE_HASH) - ) - inner_puzhash - ) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp.hex deleted file mode 100644 index 849c591ef825..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff0bff16ffff0bff04ffff0bff04ff1aff0b80ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bffff0101ff178080ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bff16ffff0bff04ffff0bff04ff1aff0580ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bffff0101ff058080ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bffff0101ff0b8080ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1affff0bffff0101ff178080ffff0bff04ff1aff12808080ff12808080ff12808080ff1280808080ffff0bff04ffff0bff1effff0bff04ffff0bff04ff1aff2f80ffff0bff04ff1aff12808080ff12808080ff12808080ff12808080ffff04ffff01ff02ffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff018080 diff --git a/chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp b/chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp deleted file mode 100644 index ba09b71656b8..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp +++ /dev/null @@ -1,64 +0,0 @@ -; This layer ensures that a second puzzle hash or "backdoor" that can be used without the inner puzzle's permission -; travels with each generation of a coin. - -; The hidden puzzle is responsible for recreating this layer if it wishes, this layer will not wrap its outputs. -(mod - ( - THIS_MOD_HASH - HIDDEN_PUZZLE_HASH - INNER_PUZZLE_HASH ; must be a hash so that the backdoor has enough info to create a puzzle reveal to spend the coin - hidden ; bool for whether or not to run the hidden puzzle - inner_or_hidden_puzzle_reveal - inner_or_hidden_solution - ) - - (include condition_codes.clib) - (include curry.clib) - (include sha256tree.clib) - (include utility_macros.clib) - - (defconstant ONE 1) - - (defun-inline wrap_puzhash - ( - THIS_MOD_HASH - HIDDEN_PUZZLE_HASH - new_inner_puzzle_hash - ) - - (curry_hashes_inline THIS_MOD_HASH - (sha256 ONE THIS_MOD_HASH) - (sha256 ONE HIDDEN_PUZZLE_HASH) - (sha256 ONE new_inner_puzzle_hash) - ) - ) - - (defun wrap_create_coins - ( - THIS_MOD_HASH - HIDDEN_PUZZLE_HASH - conditions - ) - (if conditions - (if (= (f (f conditions)) CREATE_COIN) - (c - (c CREATE_COIN (c (wrap_puzhash THIS_MOD_HASH HIDDEN_PUZZLE_HASH (f (r (f conditions)))) (r (r (f conditions))))) - (wrap_create_coins THIS_MOD_HASH HIDDEN_PUZZLE_HASH (r conditions)) - ) - (c (f conditions) (wrap_create_coins THIS_MOD_HASH HIDDEN_PUZZLE_HASH (r conditions))) - ) - () - ) - ) - - (if hidden - (assert (= HIDDEN_PUZZLE_HASH (sha256tree inner_or_hidden_puzzle_reveal)) - ; then - (a inner_or_hidden_puzzle_reveal inner_or_hidden_solution) - ) - (assert (= INNER_PUZZLE_HASH (sha256tree inner_or_hidden_puzzle_reveal)) - ; then - (wrap_create_coins THIS_MOD_HASH HIDDEN_PUZZLE_HASH (a inner_or_hidden_puzzle_reveal inner_or_hidden_solution)) - ) - ) -) diff --git a/chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp.hex b/chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp.hex deleted file mode 100644 index 012c9f872bb7..000000000000 --- a/chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp.hex +++ /dev/null @@ -1 +0,0 @@ -ff02ffff01ff02ffff03ff2fffff01ff02ffff03ffff09ff0bffff02ff16ffff04ff02ffff04ff5fff8080808080ffff01ff02ff5fff81bf80ffff01ff088080ff0180ffff01ff02ffff03ffff09ff17ffff02ff16ffff04ff02ffff04ff5fff8080808080ffff01ff02ff1effff04ff02ffff04ff05ffff04ff0bffff04ffff02ff5fff81bf80ff808080808080ffff01ff088080ff018080ff0180ffff04ffff01ffff33ff0102ffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ffff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff16ffff04ff02ffff04ff09ff80808080ffff02ff16ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff02ffff03ff17ffff01ff02ffff03ffff09ff47ff0880ffff01ff04ffff04ff08ffff04ffff0bff2affff0bff1cffff0bff1cff32ff0580ffff0bff1cffff0bff3affff0bff1cffff0bff1cff32ffff0bff14ff058080ffff0bff1cffff0bff3affff0bff1cffff0bff1cff32ffff0bff14ff0b8080ffff0bff1cffff0bff3affff0bff1cffff0bff1cff32ffff0bff14ff81a78080ffff0bff1cff32ff22808080ff22808080ff22808080ff22808080ff81e78080ffff02ff1effff04ff02ffff04ff05ffff04ff0bffff04ff37ff80808080808080ffff01ff04ff27ffff02ff1effff04ff02ffff04ff05ffff04ff0bffff04ff37ff8080808080808080ff0180ff8080ff0180ff018080 diff --git a/chia/wallet/wallet_state_manager.py b/chia/wallet/wallet_state_manager.py index a3b5be565dc6..59834c64a788 100644 --- a/chia/wallet/wallet_state_manager.py +++ b/chia/wallet/wallet_state_manager.py @@ -21,7 +21,6 @@ from chia.data_layer.data_layer_wallet import DataLayerWallet from chia.data_layer.dl_wallet_store import DataLayerStore from chia.pools.pool_puzzles import ( - SINGLETON_LAUNCHER_HASH, get_most_recent_singleton_coin_from_coin_spend, solution_to_pool_state, ) @@ -83,7 +82,7 @@ from chia.wallet.did_wallet.did_wallet import DIDWallet from chia.wallet.did_wallet.did_wallet_puzzles import DID_INNERPUZ_MOD, match_did_puzzle from chia.wallet.key_val_store import KeyValStore -from chia.wallet.nft_wallet.nft_puzzles import get_metadata_and_phs, get_new_owner_did +from chia.wallet.nft_wallet.nft_puzzle_utils import get_metadata_and_phs, get_new_owner_did from chia.wallet.nft_wallet.nft_wallet import NFTWallet from chia.wallet.nft_wallet.uncurry_nft import NFTCoinData, UncurriedNFT from chia.wallet.notification_manager import NotificationManager @@ -104,6 +103,7 @@ TransactionInfo, UnsignedTransaction, ) +from chia.wallet.singleton import SINGLETON_LAUNCHER_PUZZLE_HASH as SINGLETON_LAUNCHER_HASH from chia.wallet.singleton import create_singleton_puzzle, get_inner_puzzle_from_singleton, get_singleton_id_from_puzzle from chia.wallet.trade_manager import TradeManager from chia.wallet.trading.offer import Offer diff --git a/poetry.lock b/poetry.lock index e274e90f2d33..7ae1cbfa0ed5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. [[package]] name = "aiofiles" @@ -750,6 +750,22 @@ clvm_rs = "0.2.5" [package.extras] dev = ["black (>=23.1.0)", "pytest (>=7.2.1)", "ruff (>=0.0.252)"] +[[package]] +name = "chia-puzzles-py" +version = "0.20.1" +description = "A collection of the currently deployed ChiaLisp puzzles." +optional = false +python-versions = "<4.0,>=3.8" +files = [ + {file = "chia_puzzles_py-0.20.1-py3-none-any.whl", hash = "sha256:05feda5d148d116c0f8d6c72e9c53d3965c8141e70fedd4f802ba01777ab9da0"}, + {file = "chia_puzzles_py-0.20.1.tar.gz", hash = "sha256:d1c171042fde1269230004089c7b506d51bc86ddc5b147efd3b47a91abc37507"}, +] + +[package.dependencies] +clvm-rs = ">=0.2.3,<0.3.0" +clvm-tools-rs = ">=0.1.45,<0.2.0" +pytest = ">=8.3.3,<9.0.0" + [[package]] name = "chia-rs" version = "0.18.0" @@ -1190,7 +1206,7 @@ toml = ["tomli (>=1.2.1)"] name = "distlib" version = "0.3.7" description = "Distribution utilities" -optional = false +optional = true python-versions = "*" files = [ {file = "distlib-0.3.7-py2.py3-none-any.whl", hash = "sha256:2e24928bc811348f0feb63014e97aaae3037f2cf48712d51ae61df7fd6075057"}, @@ -1447,7 +1463,7 @@ type = ["pytest-mypy"] name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -optional = true +optional = false python-versions = ">=3.7" files = [ {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, @@ -2132,7 +2148,7 @@ files = [ name = "platformdirs" version = "3.11.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "platformdirs-3.11.0-py3-none-any.whl", hash = "sha256:e9d171d00af68be50e9202731309c4e658fd8bc76f55c11c7dd760d023bda68e"}, @@ -2147,7 +2163,7 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-co name = "pluggy" version = "1.5.0" description = "plugin and hook calling mechanisms for python" -optional = true +optional = false python-versions = ">=3.8" files = [ {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, @@ -2465,7 +2481,7 @@ tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} name = "pytest" version = "8.3.4" description = "pytest: simple powerful testing with Python" -optional = true +optional = false python-versions = ">=3.8" files = [ {file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"}, @@ -2911,7 +2927,7 @@ files = [ name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -optional = true +optional = false python-versions = ">=3.7" files = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, @@ -3010,7 +3026,7 @@ zstd = ["zstandard (>=0.18.0)"] name = "virtualenv" version = "20.26.6" description = "Virtual Python Environment builder" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "virtualenv-20.26.6-py3-none-any.whl", hash = "sha256:7345cc5b25405607a624d8418154577459c3e0277f5466dd79c49d5e492995f2"}, @@ -3336,4 +3352,4 @@ upnp = ["miniupnpc"] [metadata] lock-version = "2.0" python-versions = ">=3.9, <4" -content-hash = "16c96cee6159a1913a02c48254330659242ca87556a8d23bb1312695cee48920" +content-hash = "158d804a893f10339891f0dc32c77ab6268f63f44ea3402d1c7f4e74027f332a" diff --git a/pyproject.toml b/pyproject.toml index a4fa3a3daff5..c719e3e5d7c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -101,6 +101,7 @@ miniupnpc = { version = ">=2.2.2", source = "chia", optional = true } # {version="<=1.24.4", python = "<3.9", optional = true}, # {version=">=1.26.4", python = ">=3.9", optional = true}] ruff = { version = ">=0.8.1", optional = true } +chia-puzzles-py = "^0.20.1" [tool.poetry.extras]