minor test fixes

This commit is contained in:
Matt Hauff
2022-07-12 09:56:11 -05:00
parent 21c1352ec3
commit 1dfd2b542e
2 changed files with 19 additions and 24 deletions
+15 -20
View File
@@ -12,8 +12,8 @@ from blspy import G2Element
from chia.consensus.block_record import BlockRecord
from chia.protocols.wallet_protocol import PuzzleSolutionResponse, CoinState
from chia.wallet.db_wallet.db_wallet_puzzles import (
ACS,
ACS_PH,
ACS_MU,
ACS_MU_PH,
create_host_fullpuz,
SINGLETON_LAUNCHER,
create_host_layer_puzzle,
@@ -419,7 +419,6 @@ class DataLayerWallet:
# Make the child's puzzles
next_inner_puzzle: Program = await self.standard_wallet.get_new_puzzle(in_transaction=in_transaction)
next_db_layer_puzzle: Program = create_host_layer_puzzle(next_inner_puzzle, root_hash)
next_full_puz = create_host_fullpuz(next_inner_puzzle, root_hash, launcher_id)
# Construct the current puzzles
@@ -435,7 +434,7 @@ class DataLayerWallet:
assert singleton_record.lineage_proof.amount is not None
primaries: List[AmountWithPuzzlehash] = [
{
"puzzlehash": next_db_layer_puzzle.get_tree_hash(),
"puzzlehash": next_inner_puzzle.get_tree_hash(),
"amount": singleton_record.lineage_proof.amount,
"memos": [launcher_id, root_hash, next_inner_puzzle.get_tree_hash()],
}
@@ -444,10 +443,10 @@ class DataLayerWallet:
primaries=primaries,
coin_announcements={b"$"} if fee > 0 else None,
)
magic_condition = [-24, ACS, [[Program.to((root_hash, None)), ACS_PH], None]]
magic_condition = Program.to([-24, ACS_MU, [[Program.to((root_hash, None)), ACS_MU_PH], None]])
# TODO: This line is a hack, make_solution should allow us to pass extra conditions to it
innersol = Program.to([[], (1, magic_condition.cons(innersol.at("rfr"))), []])
db_layer_sol = Program.to([0, inner_sol, current_inner_puzzle])
inner_sol = Program.to([[], (1, magic_condition.cons(inner_sol.at("rfr"))), []])
db_layer_sol = Program.to([inner_sol])
full_sol = Program.to(
[
parent_lineage.to_program(),
@@ -615,19 +614,15 @@ class DataLayerWallet:
if condition[0] == ConditionOpcode.CREATE_COIN and int.from_bytes(condition[2], "big") % 2 == 1:
full_puzzle_hash = bytes32(condition[1])
amount = uint64(int.from_bytes(condition[2], "big"))
if current_full_puz_hash == full_puzzle_hash:
root = singleton_record.root
inner_puzzle_hash = singleton_record.inner_puzzle_hash
else:
try:
root = bytes32(condition[3][1])
inner_puzzle_hash = bytes32(condition[3][2])
except IndexError:
self.log.warning(
f"Parent {parent_name} with launcher {singleton_record.launcher_id} "
"did not hint its child properly"
)
return
try:
root = bytes32(condition[3][1])
inner_puzzle_hash = bytes32(condition[3][2])
except IndexError:
self.log.warning(
f"Parent {parent_name} with launcher {singleton_record.launcher_id} "
"did not hint its child properly"
)
return
found_singleton = True
break
+4 -4
View File
@@ -9,8 +9,8 @@ from chia.wallet.puzzles.load_clvm import load_clvm
# from chia.types.condition_opcodes import ConditionOpcode
# from chia.wallet.util.merkle_tree import MerkleTree, TreeType
ACS = Program.to(1)
ACS_PH = ACS.get_tree_hash()
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("singleton_top_layer_v1_1.clvm")
# TODO: need new data layer specific clvm
SINGLETON_LAUNCHER = load_clvm("singleton_launcher.clvm")
@@ -25,7 +25,7 @@ def create_host_fullpuz(innerpuz: Union[Program, bytes32], current_root: bytes32
def create_host_layer_puzzle(innerpuz: Union[Program, bytes32], current_root: bytes32) -> Program:
# some hard coded metadata formatting and metadata updater for now
return create_nft_layer_puzzle_with_curry_params(Program.to((current_root, None)), ACS_PH, innerpuz)
return create_nft_layer_puzzle_with_curry_params(Program.to((current_root, None)), ACS_MU_PH, innerpuz)
def match_dl_singleton(puzzle: Program) -> Tuple[bool, Iterator[Program]]:
@@ -35,7 +35,7 @@ def match_dl_singleton(puzzle: Program) -> Tuple[bool, Iterator[Program]]:
mod, singleton_curried_args = puzzle.uncurry()
if mod == SINGLETON_TOP_LAYER_MOD:
mod, dl_curried_args = singleton_curried_args.at("rf").uncurry()
if mod == NFT_STATE_LAYER_MOD and dl_curried_args.at("rrf") == ACS_PH:
if mod == NFT_STATE_LAYER_MOD and dl_curried_args.at("rrf") == ACS_MU_PH:
launcher_id = singleton_curried_args.at("frf")
root = dl_curried_args.at("rff")
innerpuz = dl_curried_args.at("rrrf")