Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Taroni
chia-blockchain
Commits
ebb8f2d5
Commit
ebb8f2d5
authored
3 years ago
by
matt
Browse files
Options
Download
Email Patches
Plain Diff
save progress before rebase
parent
20c2bf50
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
chia/wallet/puzzles/pool_escaping_innerpuz.clvm
+1
-0
chia/wallet/puzzles/pool_escaping_innerpuz.clvm
chia/wallet/puzzles/pool_member_innerpuz.clvm
+1
-0
chia/wallet/puzzles/pool_member_innerpuz.clvm
chia/wallet/puzzles/singleton_launcher.clvm
+5
-0
chia/wallet/puzzles/singleton_launcher.clvm
chia/wallet/puzzles/singleton_top_layer.clvm
+4
-0
chia/wallet/puzzles/singleton_top_layer.clvm
tests/wallet/test_singleton.py
+40
-0
tests/wallet/test_singleton.py
with
51 additions
and
0 deletions
+51
-0
chia/wallet/puzzles/pool_escaping_innerpuz.clvm
+
1
-
0
View file @
ebb8f2d5
...
...
@@ -2,6 +2,7 @@
; POOL_PUZHASH is commitment to the pool's puzzlehash
; RELATIVE_LOCK_HEIGHT is how long it takes to leave
; OWNER_PUBKEY is the farmer pubkey which signs the exit puzhash
; ESCAPE_MODE_PUZHASH is the puzzle_hash you'll go to when you iniate the leaving process
; P2_SINGLETON_PUZHASH is the puzzlehash for your pay_to_singleton puzzle
...
...
This diff is collapsed.
Click to expand it.
chia/wallet/puzzles/pool_member_innerpuz.clvm
+
1
-
0
View file @
ebb8f2d5
...
...
@@ -4,6 +4,7 @@
; RELATIVE_LOCK_HEIGHT is how long it takes to leave
; ESCAPE_MODE_PUZHASH is the puzzle_hash you'll go to when you iniate the leaving process
; P2_SINGLETON_PUZHASH is the puzzlehash for your pay to singleton puzzle
; PUBKEY is the farmer pubkey which authorises an escape attempt
; spend_type is: 0 for absorbing money, 1 to escape
...
...
This diff is collapsed.
Click to expand it.
chia/wallet/puzzles/singleton_launcher.clvm
0 → 100644
+
5
-
0
View file @
ebb8f2d5
(mod (puzhash amount)
; main
(qq (c (q. 51) (c (q . (unquote puzhash)) (c (q . (unquote amount)) ()))))
)
This diff is collapsed.
Click to expand it.
chia/wallet/puzzles/singleton_top_layer.clvm
+
4
-
0
View file @
ebb8f2d5
...
...
@@ -75,6 +75,10 @@
(sha256 (sha256 parent_parent (create_fullpuzhash mod_hash mod_hash_hash genesis_puzhash parent_innerpuz) parent_amount) (create_fullpuzhash mod_hash mod_hash_hash genesis_puzhash my_innerpuzhash) my_amount)
)
(defmacro launcher_puzhash (my_puzhash my_amount)
(qq (c (q. 51) (c (q . (unquote my_puzhash)) (c (q . (unquote my_amount)) ()))))
)
(defun check_my_amount_and_ID (mod_hash mod_hash_hash genesis_puzhash genesis_parent genesis_amount my_innerpuzhash parent_info my_amount)
(if (logand my_amount 1)
(if (l parent_info)
...
...
This diff is collapsed.
Click to expand it.
tests/wallet/test_singleton.py
+
40
-
0
View file @
ebb8f2d5
from
chia.wallet.puzzles.load_clvm
import
load_clvm
from
chia.types.blockchain_format.program
import
Program
,
INFINITE_COST
from
chia.types.announcement
import
Announcement
from
chia.types.blockchain_format.coin
import
Coin
from
chia.types.blockchain_format.sized_bytes
import
bytes32
SINGLETON_MOD
=
load_clvm
(
"singleton_top_layer.clvm"
)
P2_SINGLETON_MOD
=
load_clvm
(
"p2_singleton.clvm"
)
POOL_COMMITED_MOD
=
load_clvm
(
"pool_member_innerpuz.clvm"
)
POOL_ESCAPING_MOD
=
load_clvm
(
"pool_escaping_innerpuz.clvm"
)
def
test_only_odd_coins
():
...
...
@@ -94,3 +98,39 @@ def test_p2_singleton():
INFINITE_COST
,
Program
.
to
([
innerpuz
.
get_tree_hash
(),
p2_singleton_coin_id
])
)
assert
result
.
first
().
rest
().
first
().
as_atom
()
==
expected_announcement
def
test_pool_puzzles
():
singleton_mod_hash
=
SINGLETON_MOD
.
get_tree_hash
()
genesis_id
=
0xCAFEF00D
genesis_challenge
=
bytes
.
fromhex
(
"ccd5bb71183532bff220ba46c268991a3ff07eb358e8255a65c30a2dce0e5fbb"
)
block_height
=
101
# 0x65
pool_reward_parent_id
=
bytes32
(
genesis_challenge
[:
16
]
+
block_height
.
to_bytes
(
16
,
"big"
))
p2_singleton_full
=
P2_SINGLETON_MOD
.
curry
(
singleton_mod_hash
,
Program
.
to
(
singleton_mod_hash
).
get_tree_hash
(),
genesis_id
)
p2_singleton_full_puzhash
=
p2_singleton_full
.
get_tree_hash
()
p2_singlton_coin_amount
=
2000000000
p2_singleton_coin_id
=
Coin
(
pool_reward_parent_id
,
p2_singleton_full_puzhash
,
p2_singlton_coin_amount
).
name
()
pool_puzhash
=
0xd34db33f
relative_lock_height
=
600
owner_pubkey
=
0xFADEDDAB
# Curry params are POOL_PUZHASH, RELATIVE_LOCK_HEIGHT, OWNER_PUBKEY, P2_SINGLETON_PUZHASH
escape_innerpuz
=
POOL_ESCAPING_MOD
.
curry
(
pool_puzhash
,
relative_lock_height
,
owner_pubkey
,
p2_singleton_full_puzhash
)
# Curry params are POOL_PUZHASH, RELATIVE_LOCK_HEIGHT, ESCAPE_MODE_PUZHASH, P2_SINGLETON_PUZHASH, PUBKEY
committed_innerpuz
=
POOL_COMMITED_MOD
.
curry
(
pool_puzhash
,
relative_lock_height
,
escape_innerpuz
.
get_tree_hash
(),
p2_singleton_full_puzhash
,
owner_pubkey
)
singleton_full
=
SINGLETON_MOD
.
curry
(
singleton_mod_hash
,
genesis_id
,
committed_innerpuz
)
singleton_amount
=
3
# innersol = spend_type, my_puzhash, my_amount, pool_reward_amount, pool_reward_height
inner_sol
=
Program
.
to
([
0
,
singleton_full
.
get_tree_hash
(),
singleton_amount
,
p2_singlton_coin_amount
,
block_height
])
full_sol
=
Program
.
to
([
genesis_id
,
singleton_amount
,
inner_sol
])
cost
,
result
=
singleton_full
.
run_with_cost
(
INFINITE_COST
,
full_sol
)
# result = '((70 0x196fde08c221af2dfc00c4d281a3a7969cda6791cf97fe2dcf10d5f25b7efdb4) (51 0xfee0b1f4d6c86e0e34f3e3e253482a0db29436dd30891809333a2d094540b6f7 3) (72 0xfee0b1f4d6c86e0e34f3e3e253482a0db29436dd30891809333a2d094540b6f7) (73 3) (51 0x00d34db33f 0x77359400) (62 0x5bfd313e20659e7da5e1f9c165b83b342a0d32974ae80a090a3f1857e3331fde) (61 0x7b17ee829e409d2132a6ccebb9b064746eb68888c51082bb6373788f71702b77))'
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help