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

Add TreeHasher to simplify currying puzzle hashes #503

Merged
merged 3 commits into from
May 11, 2024
Merged

Conversation

Rigidity
Copy link
Contributor

@Rigidity Rigidity commented May 6, 2024

Instead of having to special case untyped currying code with curry_tree_hash for each puzzle type, you can use CurriedProgram directly now. Here is an example:

let puzzle_hash = CurriedProgram {
    program: CAT_PUZZLE_HASH,
    args: CatArgs {
        mod_hash: CAT_PUZZLE_HASH.into(),
        tail_program_hash: CurriedProgram {
            program: GENESIS_BY_COIN_ID_TAIL_PUZZLE_HASH,
            args: GenesisByCoinIdTailArgs {
                genesis_coin_id: Bytes32::default(),
            },
        }
        .tree_hash()
        .into(),
        inner_puzzle: CurriedProgram {
            program: STANDARD_PUZZLE_HASH,
            args: StandardArgs {
                synthetic_key: PublicKey::default(),
            },
        },
    },
}
.tree_hash();

@Rigidity Rigidity requested a review from arvidn May 6, 2024 23:54
Copy link

coveralls-official bot commented May 7, 2024

Pull Request Test Coverage Report for Build 9041115025

Details

  • 158 of 173 (91.33%) changed or added relevant lines in 10 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.002%) to 84.076%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/clvm-utils/src/tree_hash.rs 28 43 65.12%
Files with Coverage Reduction New Missed Lines %
crates/chia-protocol/src/bytes.rs 3 86.54%
Totals Coverage Status
Change from base Build 9011508250: -0.002%
Covered Lines: 11832
Relevant Lines: 14073

💛 - Coveralls

crates/clvm-utils/src/hash_encoder.rs Outdated Show resolved Hide resolved
crates/chia-puzzles/src/puzzles/offer.rs Show resolved Hide resolved
crates/chia-puzzles/src/puzzles/cat.rs Outdated Show resolved Hide resolved
crates/chia-puzzles/src/derive_synthetic.rs Outdated Show resolved Hide resolved
crates/chia-puzzles/src/puzzles/cat.rs Outdated Show resolved Hide resolved
@Rigidity Rigidity force-pushed the tree-hasher branch 2 times, most recently from 313e6be to 128f0c6 Compare May 7, 2024 16:50
@Rigidity Rigidity requested a review from arvidn May 7, 2024 16:54
@Rigidity Rigidity changed the title Add TreeHasher for encoding TreeHash CLVM values directly Add TreeHasher to simplify currying puzzle hashes May 7, 2024
@Rigidity Rigidity merged commit 3c8cec4 into main May 11, 2024
64 checks passed
@Rigidity Rigidity deleted the tree-hasher branch May 11, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants