Skip to content

fix(validate): check reference scripts as source for minting policies#686

Merged
scarmuega merged 3 commits into
mainfrom
fix/check-ref-scripts
Aug 14, 2025
Merged

fix(validate): check reference scripts as source for minting policies#686
scarmuega merged 3 commits into
mainfrom
fix/check-ref-scripts

Conversation

@scarmuega
Copy link
Copy Markdown
Member

@scarmuega scarmuega commented Aug 14, 2025

Summary by CodeRabbit

  • Breaking Changes

    • Updated check_minting method signature to accept additional UTxO data parameter.
  • New Features

    • Added support for reference-input scripts in minting validation.
  • Improvements

    • Enhanced error reporting to include specific missing policy hashes in validation failures.
    • Consolidated minting script validation into unified validation flow.

@scarmuega scarmuega merged commit 61fe260 into main Aug 14, 2025
12 of 14 checks passed
@scarmuega scarmuega deleted the fix/check-ref-scripts branch August 14, 2025 13:11
@rodrigosuaya
Copy link
Copy Markdown

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 18, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 18, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The minting validation flow is refactored to aggregate script witnesses from native scripts, Plutus v1/v2/v3 scripts, and reference-input scripts into a single collection, replacing separate per-script witness vectors. The check_minting function signature now accepts utxos to resolve reference-input scripts. The MintingLacksPolicy error is enhanced to carry the specific missing policy hash.

Changes

Cohort / File(s) Summary
Minting validation refactoring
pallas-validate/src/phase1/babbage.rs, pallas-validate/src/phase1/conway.rs
Updated check_minting function signature to accept utxos parameter; refactored minting validation to aggregate native script, Plutus v1/v2/v3 script, and reference-input script hashes into single all_scripts_wits collection; replaced per-script containment checks with single aggregate validation; added debug print of collected witnesses; updated call sites to pass utxos
Error type enhancement
pallas-validate/src/utils/validation.rs
Modified MintingLacksPolicy enum variant from unit-like to tuple-like, now carrying pallas_crypto::hash::Hash<28> payload; updated error message formatting to include the missing policy hash
Test adaptation
pallas-validate/tests/babbage.rs
Updated match arm for MintingLacksPolicy from MintingLacksPolicy to MintingLacksPolicy(_) to destructure and ignore the new payload

Sequence Diagram

sequenceDiagram
    participant TxValidator
    participant CheckMinting
    participant WitnessSet as Witness Set
    participant RefInputs as UTxOs (Reference Inputs)
    participant AllScriptsWits as all_scripts_wits<br/>(Aggregated)

    TxValidator->>CheckMinting: check_minting(tx_body, mtx, utxos)
    
    CheckMinting->>WitnessSet: Extract native script hashes
    WitnessSet-->>CheckMinting: native_script_hashes
    
    CheckMinting->>WitnessSet: Extract Plutus v1/v2/v3 script hashes
    WitnessSet-->>CheckMinting: plutus_script_hashes
    
    CheckMinting->>RefInputs: get_script_hash_from_reference_input()
    RefInputs-->>CheckMinting: reference_input_script_hashes
    
    CheckMinting->>AllScriptsWits: Aggregate all hashes
    
    rect rgb(220, 240, 255)
        Note over CheckMinting,AllScriptsWits: Unified validation
        CheckMinting->>AllScriptsWits: For each minted policy:<br/>contains(all_scripts_wits)?
        alt Policy found
            AllScriptsWits-->>CheckMinting: ✓ Valid
        else Policy missing
            AllScriptsWits-->>CheckMinting: ✗ MintingLacksPolicy(policy_hash)
        end
    end
    
    CheckMinting-->>TxValidator: Result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Rationale: Changes span three files with interconnected logic and signature updates. The refactoring introduces new parameter threading (utxos) across validation functions and modifies a public enum variant that cascades to test adjustments. While the pattern is consistent and repetition is moderate, the coordination across validation phases and error handling requires careful verification of completeness across call sites.

Poem

🐰 Scripts once scattered, now they unite,
Gathered from witnesses, shining so bright,
Reference inputs dance with native script grace,
Aggregated hashes in one sacred place,
Validation flows swift, with policy in hand,
A chorus of scripts, so perfectly planned!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/check-ref-scripts

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c1e086 and ad93c80.

📒 Files selected for processing (4)
  • pallas-validate/src/phase1/babbage.rs (4 hunks)
  • pallas-validate/src/phase1/conway.rs (4 hunks)
  • pallas-validate/src/utils/validation.rs (1 hunks)
  • pallas-validate/tests/babbage.rs (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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