Skip to content

validate(conway): native reference scripts misclassified as phase-2 in redeemer pointer check #762

Description

@scarmuega

Summary

In Conway phase-1 validation, is_phase_2_script (pallas-validate/src/phase1/conway.rs:1256) treats any hash present in reference_scripts as a Plutus script. But get_reference_script_hashes (conway.rs:776) builds that list from all reference scripts — including native scripts — so a native-script credential satisfied via a reference input is wrongly classified as needing a Plutus redeemer.

Effect: mk_plutus_script_redeemer_pointers emits a RedeemerTag::{Spend,Mint,Reward} pointer for the native-script hash, then redeemer_key_coincide fails with RedeemerMissing on a transaction that is actually valid.

Where

  • get_script_hash_from_reference_input (conway.rs:863) hashes ScriptRef::NativeScript, PlutusV1Script, PlutusV2Script, PlutusV3Script into the same Vec<PolicyId> with no kind tag.
  • check_redeemers (conway.rs:1107) passes that vec straight into mk_plutus_script_redeemer_pointers (conway.rs:1184).
  • mk_plutus_script_redeemer_pointers calls is_phase_2_script for the Spend, Mint, and Reward branches (lines 1194, 1210, 1236) — all three inherit the misclassification.

The Reward branch was added in #761, but the bug pre-exists for Spend and Mint on main.

Suggested fix

Filter at the source. Either:

  1. Change get_reference_script_hashes to return only Plutus reference-script hashes (skip the ScriptRef::NativeScript arm in get_script_hash_from_reference_input for this consumer), or
  2. Return Vec<(PolicyId, ScriptKind)> and have is_phase_2_script branch on kind so native reference scripts are never matched as phase-2.

(1) is the smaller change; (2) is more correct long-term if any other call site needs to know the kind.

Test plan

  • Add a Conway phase-1 test with a native-script-locked withdrawal satisfied via a reference input — current behavior fails with RedeemerMissing, fixed behavior validates.
  • Mirror the test for Spend (input locked by native reference script) and Mint (native policy provided as reference script).

Reported by CodeRabbit on #761.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions