-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add puzzles, driver and lifecycle tests for revocable CATs #19000
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; This is a "limitations_program" for use with cat.clsp. | ||
; It allows an issuer vault to mint and a melter vault to melt this CAT. | ||
(mod ( | ||
SINGLETON_MOD_HASH | ||
LAUNCHER_PUZZLE_HASH | ||
ISSUER_LAUNCHER_ID | ||
MELTER_LAUNCHER_ID | ||
NONCE | ||
Truths | ||
parent_is_cat | ||
lineage_proof | ||
delta | ||
inner_conditions | ||
( ; solution | ||
singleton_inner_puzzle_hash | ||
) | ||
) | ||
|
||
(include condition_codes.clib) | ||
(include 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 | ||
(sha256tree SINGLETON_STRUCT) | ||
) | ||
) | ||
|
||
(defun-inline authorize_via_singleton (SINGLETON_STRUCT singleton_inner_puzzle_hash delta) | ||
(list | ||
(list RECEIVE_MESSAGE 23 delta (calculate_full_puzzle_hash SINGLETON_STRUCT singleton_inner_puzzle_hash)) | ||
) | ||
) | ||
|
||
(defun-inline singleton_struct_for_delta (ISSUER_LAUNCHER_ID MELTER_LAUNCHER_ID delta) | ||
(if (> 0 delta) | ||
(c SINGLETON_MOD_HASH (c MELTER_LAUNCHER_ID LAUNCHER_PUZZLE_HASH)) ; delta is negative, so we melt | ||
(c SINGLETON_MOD_HASH (c ISSUER_LAUNCHER_ID LAUNCHER_PUZZLE_HASH)) ; delta is positive or 0, so we mint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure you should swap this with a |
||
) | ||
) | ||
|
||
(authorize_via_singleton (singleton_struct_for_delta ISSUER_LAUNCHER_ID MELTER_LAUNCHER_ID delta) singleton_inner_puzzle_hash delta) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ff02ffff01ff04ffff04ff08ffff04ffff0117ffff04ffff02ff0effff04ff02ffff04ff2fff80808080ffff04ffff0bff2affff0bff0cffff0bff0cff32ff0580ffff0bff0cffff0bff3affff0bff0cffff0bff0cff32ff0b80ffff0bff0cffff0bff3affff0bff0cffff0bff0cff32ff1780ffff0bff0cff32ff22808080ff22808080ff22808080ff8080808080ffff02ff2fff5f8080ffff04ffff01ffff4302ffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ff09ff80808080ffff02ff0effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 | ||
ff02ffff01ff04ffff04ff08ffff04ffff0117ffff04ffff02ff0effff04ff02ffff04ff5fff80808080ffff04ffff0bff2affff0bff0cffff0bff0cff32ff0580ffff0bff0cffff0bff3affff0bff0cffff0bff0cff32ff0b80ffff0bff0cffff0bff3affff0bff0cffff0bff0cff32ff2f80ffff0bff0cff32ff22808080ff22808080ff22808080ff8080808080ffff02ff5fff81bf8080ffff04ffff01ffff4302ffffffa04bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459aa09dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2ffa102a12871fee210fb8619291eaea194581cbd2531e4b23759d225f6806923f63222a102a8d5dd63fba471ebcb1f3e8f7c1e1879b7152a6e7298a91ce119a63400ade7c5ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ff09ff80808080ffff02ff0effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,15 +34,19 @@ | |
|
||
|
||
# Basic drivers | ||
def construct_p2_delegated_by_singleton(issuer_launcher_id: bytes32) -> Program: | ||
def construct_p2_delegated_by_singleton( | ||
issuer_launcher_id: bytes32, nonce=0 | ||
) -> Program: | ||
singleton_struct: Program = Program.to( | ||
( | ||
SINGLETON_TOP_LAYER_MOD_HASH, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's important in these drivers to have optional ways to override these values. Sometimes, in tests, I like to use a "mock" singleton puzzle, and these drivers wouldn't work for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same goes for similar functions below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good idea, although as you said, I don't think that driver will be merged into chia-blockchain anytime soon. |
||
(issuer_launcher_id, SINGLETON_LAUNCHER_PUZZLE_HASH), | ||
) | ||
) | ||
return P2_DELEGATED_BY_SINGLETON.curry( | ||
SINGLETON_TOP_LAYER_MOD_HASH, singleton_struct.get_tree_hash() | ||
SINGLETON_TOP_LAYER_MOD_HASH, | ||
singleton_struct.get_tree_hash(), | ||
Program.to(nonce), | ||
) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a comment about what bits these are and what that means