Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clvm mypie #16898

Merged
merged 47 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1166b50
clvm mypie
altendky Nov 21, 2023
78d6865
Merge branch 'main' into clvm_mypie
altendky Dec 19, 2023
1ee1633
update exclusions
altendky Dec 19, 2023
767cc27
wip
altendky Dec 20, 2023
071f1e7
Merge branch 'main' into clvm_mypie
altendky Dec 21, 2023
11b5595
some
altendky Dec 21, 2023
8b09ee9
undo for now
altendky Dec 22, 2023
2fe2498
more
altendky Dec 22, 2023
993fd72
Merge branch 'main' into clvm_mypie
altendky Dec 23, 2023
14362a8
more
altendky Dec 24, 2023
b8bcc46
Merge branch 'main' into clvm_mypie
altendky Dec 27, 2023
b19325a
drop the program usage in datalayer tests
altendky Dec 27, 2023
f0e88ee
ignore tree hash errors
altendky Dec 27, 2023
3d528db
ignore enough in _sexp_replace...
altendky Dec 27, 2023
c6bc0fa
Merge branch 'main' into clvm_mypie
AmineKhaldi Jan 25, 2024
e98ad08
Merge branch 'main' into clvm_mypie
altendky Mar 15, 2024
602d899
again
altendky Mar 15, 2024
74eb8b2
almost
altendky Mar 15, 2024
93852d7
Fix test_singleton.py
Quexington Mar 15, 2024
533a3ab
dl fixup
altendky Mar 15, 2024
62c0661
did fixup
altendky Mar 15, 2024
c25780c
touchup
altendky Mar 15, 2024
17a7039
nft fixup
altendky Mar 15, 2024
5df1a70
fixup tests
altendky Mar 15, 2024
f282e63
Revert "fixup tests"
altendky Mar 15, 2024
6049ed3
or this i guess
altendky Mar 15, 2024
894f5e4
blah
altendky Mar 16, 2024
9c3cb36
Fix get_owner_did
Quexington Mar 18, 2024
5578369
tidy
altendky Mar 18, 2024
e0381a1
blah
altendky Mar 18, 2024
9cfc11a
`.as_atom()`
altendky Mar 20, 2024
bbc1e96
`.as_int()`
altendky Mar 20, 2024
b7f8058
Update chia/wallet/nft_wallet/nft_puzzles.py
altendky Mar 20, 2024
4d77049
`rrrff`
altendky Mar 20, 2024
62d3950
Merge branch 'main' into clvm_mypie
altendky Mar 21, 2024
b42e703
stop using `CastableType`
altendky Mar 22, 2024
46a7a77
undo stuff around using `CastableType`
altendky Mar 22, 2024
3c7fd15
Merge branch 'main' into clvm_mypie
altendky Mar 25, 2024
d79ac98
`announcement_assertions: List[Program]`
altendky Mar 25, 2024
061eaa1
Update chia/types/blockchain_format/program.py
altendky Apr 2, 2024
d29a259
Merge branch 'main' into clvm_mypie
altendky Apr 16, 2024
11debfc
Merge main into clvm_mypie
AmineKhaldi Apr 22, 2024
01c602b
Merge branch 'main' into clvm_mypie
altendky May 7, 2024
63858f1
more
altendky May 7, 2024
e265924
clvm==0.9.10
altendky May 7, 2024
037d882
Merge branch 'main' into clvm_mypie
altendky May 13, 2024
f3827cd
Merge branch 'main' into clvm_mypie
altendky May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmarks/mempool-long-lived.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.full_node.mempool_manager import MempoolManager
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_record import CoinRecord
from chia.types.coin_spend import CoinSpend
Expand Down Expand Up @@ -44,7 +44,7 @@ def is_transaction_block(self) -> bool:
return self.timestamp is not None


IDENTITY_PUZZLE = Program.to(1)
IDENTITY_PUZZLE = SerializedProgram.to(1)
IDENTITY_PUZZLE_HASH = IDENTITY_PUZZLE.get_tree_hash()


Expand All @@ -62,7 +62,7 @@ def make_spend_bundle(coin: Coin, height: int) -> SpendBundle:
int_to_bytes(coin.amount // 2 - height * 10),
],
]
spend = CoinSpend(coin, IDENTITY_PUZZLE, Program.to(conditions))
spend = CoinSpend(coin, IDENTITY_PUZZLE, SerializedProgram.to(conditions))
return SpendBundle([spend], G2Element())


Expand Down
126 changes: 59 additions & 67 deletions chia/_tests/core/data_layer/test_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ async def test_build_a_tree(
example = await create_example(data_store, store_id)

await _debug_dump(db=data_store.db_wrapper, description="final")
actual = await data_store.get_tree_as_program(store_id=store_id)
actual = await data_store.get_tree_as_nodes(store_id=store_id)
# print("actual ", actual.as_python())
# print("expected", example.expected.as_python())
assert actual == example.expected
Expand Down Expand Up @@ -747,30 +747,28 @@ async def test_autoinsert_balances_gaps(data_store: DataStore, store_id: bytes32
async def test_delete_from_left_both_terminal(data_store: DataStore, store_id: bytes32) -> None:
await add_01234567_example(data_store=data_store, store_id=store_id)

expected = Program.to(
(
(
(
(b"\x00", b"\x10\x00"),
(b"\x01", b"\x11\x01"),
),
(
(b"\x02", b"\x12\x02"),
(b"\x03", b"\x13\x03"),
),
expected = InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x00", value=b"\x10\x00"),
right=TerminalNode.from_key_value(key=b"\x01", value=b"\x11\x01"),
),
(
(b"\x05", b"\x15\x05"),
(
(b"\x06", b"\x16\x06"),
(b"\x07", b"\x17\x07"),
),
right=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x02", value=b"\x12\x02"),
right=TerminalNode.from_key_value(key=b"\x03", value=b"\x13\x03"),
),
),
right=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x05", value=b"\x15\x05"),
right=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x06", value=b"\x16\x06"),
right=TerminalNode.from_key_value(key=b"\x07", value=b"\x17\x07"),
),
),
)

await data_store.delete(key=b"\x04", store_id=store_id, status=Status.COMMITTED)
result = await data_store.get_tree_as_program(store_id=store_id)
result = await data_store.get_tree_as_nodes(store_id=store_id)

assert result == expected

Expand All @@ -779,28 +777,26 @@ async def test_delete_from_left_both_terminal(data_store: DataStore, store_id: b
async def test_delete_from_left_other_not_terminal(data_store: DataStore, store_id: bytes32) -> None:
await add_01234567_example(data_store=data_store, store_id=store_id)

expected = Program.to(
(
(
(
(b"\x00", b"\x10\x00"),
(b"\x01", b"\x11\x01"),
),
(
(b"\x02", b"\x12\x02"),
(b"\x03", b"\x13\x03"),
),
expected = InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x00", value=b"\x10\x00"),
right=TerminalNode.from_key_value(key=b"\x01", value=b"\x11\x01"),
),
(
(b"\x06", b"\x16\x06"),
(b"\x07", b"\x17\x07"),
right=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x02", value=b"\x12\x02"),
right=TerminalNode.from_key_value(key=b"\x03", value=b"\x13\x03"),
),
),
right=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x06", value=b"\x16\x06"),
right=TerminalNode.from_key_value(key=b"\x07", value=b"\x17\x07"),
),
)

await data_store.delete(key=b"\x04", store_id=store_id, status=Status.COMMITTED)
await data_store.delete(key=b"\x05", store_id=store_id, status=Status.COMMITTED)
result = await data_store.get_tree_as_program(store_id=store_id)
result = await data_store.get_tree_as_nodes(store_id=store_id)

assert result == expected

Expand All @@ -809,30 +805,28 @@ async def test_delete_from_left_other_not_terminal(data_store: DataStore, store_
async def test_delete_from_right_both_terminal(data_store: DataStore, store_id: bytes32) -> None:
await add_01234567_example(data_store=data_store, store_id=store_id)

expected = Program.to(
(
(
(
(b"\x00", b"\x10\x00"),
(b"\x01", b"\x11\x01"),
),
(b"\x02", b"\x12\x02"),
expected = InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x00", value=b"\x10\x00"),
right=TerminalNode.from_key_value(key=b"\x01", value=b"\x11\x01"),
),
(
(
(b"\x04", b"\x14\x04"),
(b"\x05", b"\x15\x05"),
),
(
(b"\x06", b"\x16\x06"),
(b"\x07", b"\x17\x07"),
),
right=TerminalNode.from_key_value(key=b"\x02", value=b"\x12\x02"),
),
right=InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x04", value=b"\x14\x04"),
right=TerminalNode.from_key_value(key=b"\x05", value=b"\x15\x05"),
),
right=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x06", value=b"\x16\x06"),
right=TerminalNode.from_key_value(key=b"\x07", value=b"\x17\x07"),
),
),
)

await data_store.delete(key=b"\x03", store_id=store_id, status=Status.COMMITTED)
result = await data_store.get_tree_as_program(store_id=store_id)
result = await data_store.get_tree_as_nodes(store_id=store_id)

assert result == expected

Expand All @@ -841,28 +835,26 @@ async def test_delete_from_right_both_terminal(data_store: DataStore, store_id:
async def test_delete_from_right_other_not_terminal(data_store: DataStore, store_id: bytes32) -> None:
await add_01234567_example(data_store=data_store, store_id=store_id)

expected = Program.to(
(
(
(b"\x00", b"\x10\x00"),
(b"\x01", b"\x11\x01"),
expected = InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x00", value=b"\x10\x00"),
right=TerminalNode.from_key_value(key=b"\x01", value=b"\x11\x01"),
),
right=InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x04", value=b"\x14\x04"),
right=TerminalNode.from_key_value(key=b"\x05", value=b"\x15\x05"),
),
(
(
(b"\x04", b"\x14\x04"),
(b"\x05", b"\x15\x05"),
),
(
(b"\x06", b"\x16\x06"),
(b"\x07", b"\x17\x07"),
),
right=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x06", value=b"\x16\x06"),
right=TerminalNode.from_key_value(key=b"\x07", value=b"\x17\x07"),
),
),
)

await data_store.delete(key=b"\x03", store_id=store_id, status=Status.COMMITTED)
await data_store.delete(key=b"\x02", store_id=store_id, status=Status.COMMITTED)
result = await data_store.get_tree_as_program(store_id=store_id)
result = await data_store.get_tree_as_nodes(store_id=store_id)

assert result == expected

Expand Down
60 changes: 28 additions & 32 deletions chia/_tests/core/data_layer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dataclasses import dataclass
from typing import IO, TYPE_CHECKING, Any, Dict, Iterator, List, Literal, Optional, Union, overload

from chia.data_layer.data_layer_util import NodeType, Side, Status
from chia.data_layer.data_layer_util import InternalNode, Node, NodeType, Side, Status, TerminalNode
from chia.data_layer.data_store import DataStore
from chia.types.blockchain_format.program import Program
from chia.types.blockchain_format.sized_bytes import bytes32
Expand Down Expand Up @@ -47,21 +47,19 @@ async def general_insert(

@dataclass(frozen=True)
class Example:
expected: Program
expected: Node
terminal_nodes: List[bytes32]


async def add_0123_example(data_store: DataStore, store_id: bytes32) -> Example:
expected = Program.to(
(
(
(b"\x00", b"\x10\x00"),
(b"\x01", b"\x11\x01"),
),
(
(b"\x02", b"\x12\x02"),
(b"\x03", b"\x13\x03"),
),
expected = InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x00", value=b"\x10\x00"),
right=TerminalNode.from_key_value(key=b"\x01", value=b"\x11\x01"),
),
right=InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x02", value=b"\x12\x02"),
right=TerminalNode.from_key_value(key=b"\x03", value=b"\x13\x03"),
),
)

Expand All @@ -76,27 +74,25 @@ async def add_0123_example(data_store: DataStore, store_id: bytes32) -> Example:


async def add_01234567_example(data_store: DataStore, store_id: bytes32) -> Example:
expected = Program.to(
(
(
(
(b"\x00", b"\x10\x00"),
(b"\x01", b"\x11\x01"),
),
(
(b"\x02", b"\x12\x02"),
(b"\x03", b"\x13\x03"),
),
expected = InternalNode.from_child_nodes(
left=InternalNode.from_child_nodes(
InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x00", value=b"\x10\x00"),
right=TerminalNode.from_key_value(key=b"\x01", value=b"\x11\x01"),
),
InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x02", value=b"\x12\x02"),
right=TerminalNode.from_key_value(key=b"\x03", value=b"\x13\x03"),
),
),
right=InternalNode.from_child_nodes(
InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x04", value=b"\x14\x04"),
right=TerminalNode.from_key_value(key=b"\x05", value=b"\x15\x05"),
),
(
(
(b"\x04", b"\x14\x04"),
(b"\x05", b"\x15\x05"),
),
(
(b"\x06", b"\x16\x06"),
(b"\x07", b"\x17\x07"),
),
InternalNode.from_child_nodes(
left=TerminalNode.from_key_value(key=b"\x06", value=b"\x16\x06"),
right=TerminalNode.from_key_value(key=b"\x07", value=b"\x17\x07"),
),
),
)
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/generator/test_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import pytest
from chia_rs import ALLOW_BACKREFS
from clvm import SExp
from clvm.serialize import sexp_from_stream
from clvm.SExp import SExp
from clvm_tools import binutils

from chia._tests.core.make_block_generator import make_spend_bundle
Expand Down
3 changes: 2 additions & 1 deletion chia/_tests/generator/test_rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import List, Tuple

from clvm.CLVMObject import CLVMStorage
from clvm_tools import binutils
from clvm_tools.clvmc import compile_clvm_text

Expand Down Expand Up @@ -84,7 +85,7 @@ def run_generator(self: BlockGenerator) -> Tuple[int, Program]:
return GENERATOR_MOD.run_with_cost(MAX_COST, [self.program, args])


def as_atom_list(prg: Program) -> List[bytes]:
def as_atom_list(prg: CLVMStorage) -> List[bytes]:
"""
Pretend `prg` is a list of atoms. Return the corresponding
python list of atoms.
Expand Down
9 changes: 4 additions & 5 deletions chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any, Dict, List, Optional, cast
from typing import Any, Dict, List, Optional

import pytest
from chia_rs import G2Element
Expand Down Expand Up @@ -32,8 +32,7 @@

# Some methods mapping strings to CATs
def str_to_tail(tail_str: str) -> Program:
# TODO: Remove cast when we improve typing
return cast(Program, Program.to([3, [], [1, tail_str], []]))
return Program.to([3, [], [1, tail_str], []])


def str_to_tail_hash(tail_str: str) -> bytes32:
Expand Down Expand Up @@ -118,10 +117,10 @@ def generate_secure_bundle(
offered_amount: uint64,
tail_str: Optional[str] = None,
) -> SpendBundle:
announcement_assertions = [a.to_program() for a in announcements]
announcement_assertions: List[Program] = [a.to_program() for a in announcements]
selected_coin_amount = sum([c.amount for c in selected_coins])
non_primaries = [] if len(selected_coins) < 2 else selected_coins[1:]
inner_solution: List[List[Any]] = [
inner_solution: List[Any] = [
[51, Offer.ph(), offered_amount], # Offered coin
[51, acs_ph, uint64(selected_coin_amount - offered_amount)], # Change
*announcement_assertions,
Expand Down
10 changes: 5 additions & 5 deletions chia/_tests/wallet/dao_wallet/test_dao_clvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ def test_proposal() -> None:
treasury_inner,
)
treasury_puzhash = treasury.get_tree_hash()
apa_msg = singleton_id
apa_msg_bytes = singleton_id

timer_apa = std_hash(timer_puzhash + singleton_id)
assert conds[ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT][0].vars[0] == timer_apa
assert conds[ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT][1].vars[0] == std_hash(treasury_puzhash + apa_msg)
assert conds[ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT][1].vars[0] == std_hash(treasury_puzhash + apa_msg_bytes)

# close a failed proposal
full_proposal = proposal_curry_one.curry(
Expand All @@ -347,8 +347,8 @@ def test_proposal() -> None:
]
)
conds = conditions_dict_for_solution(full_proposal, solution, INFINITE_COST)
apa_msg = int_to_bytes(0)
assert conds[ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT][1].vars[0] == std_hash(treasury_puzhash + apa_msg)
apa_msg_int = int_to_bytes(0)
assert conds[ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT][1].vars[0] == std_hash(treasury_puzhash + apa_msg_int)
assert conds[ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT][0].vars[0] == timer_apa

finished_puz = DAO_FINISHED_STATE.curry(singleton_struct, DAO_FINISHED_STATE_HASH)
Expand All @@ -373,7 +373,7 @@ def test_proposal() -> None:
]
)
conds = conditions_dict_for_solution(full_proposal, solution, INFINITE_COST)
assert conds[ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT][0].vars[0] == std_hash(treasury_puzhash + apa_msg)
assert conds[ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT][0].vars[0] == std_hash(treasury_puzhash + apa_msg_int)
assert conds[ConditionOpcode.CREATE_COIN][0].vars[0] == finished_puz.get_tree_hash()


Expand Down
Loading
Loading