fix(validate): include withdrawals in conway redeemer pointer check#761
Conversation
📝 WalkthroughWalkthroughThis PR adds fallible reward redeemer pointer generation for Conway transactions. The ChangesReward Redeemer Pointer Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pallas-validate/src/phase1/conway.rs (1)
1154-1246: ⚡ Quick winAdd a regression test for reward-account ordering and decode failures.
This logic is subtle enough that it should be locked down with a Conway test covering: mixed key/script withdrawals across at least two networks, and a malformed withdrawal key that must now surface
PostAlonzo(InputDecoding)instead of panicking. That would protect both the new comparator and the new fallible parsing path.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pallas-validate/src/phase1/conway.rs` around lines 1154 - 1246, Add a Conway regression test that covers reward-account ordering and decode failures: exercise sort_reward_accounts and mk_plutus_script_redeemer_pointers by building a TransactionBody with withdrawals containing mixed key vs script stake addresses across at least two networks (Testnet and Mainnet) and assert the produced RedeemersKey entries for RedeemerTag::Reward are in the expected sorted order (scripts vs keys and by payload hash/network tag). Also include a malformed withdrawal key (invalid address bytes) and assert mk_plutus_script_redeemer_pointers returns Err(PostAlonzo(InputDecoding)) rather than panicking. Ensure the test imports/uses the same helper functions/types (sort_reward_accounts, mk_plutus_script_redeemer_pointers, StakeAddress, Address, RedeemersKey, RedeemerTag) so it will catch regressions in both the comparator and the fallible parsing path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pallas-validate/src/phase1/conway.rs`:
- Around line 1231-1237: The call to is_phase_2_script is being passed the full
reference_scripts collection which includes native scripts; filter
reference_scripts to only Plutus reference hashes (or otherwise pass the script
kind with each hash) before calling is_phase_2_script so native reference
scripts are excluded from the Plutus redeemer decision. Locate the call to
is_phase_2_script (the invocation that currently passes reference_scripts along
with plutus_v1_scripts, plutus_v2_scripts, plutus_v3_scripts) and replace the
reference_scripts argument with a filtered iterator/collection containing only
Plutus script hashes (e.g., map/filter to select Plutus kinds) or change the API
to accept (hash, kind) pairs and branch on kind so native scripts are not
treated as Phase 2/Plutus scripts.
---
Nitpick comments:
In `@pallas-validate/src/phase1/conway.rs`:
- Around line 1154-1246: Add a Conway regression test that covers reward-account
ordering and decode failures: exercise sort_reward_accounts and
mk_plutus_script_redeemer_pointers by building a TransactionBody with
withdrawals containing mixed key vs script stake addresses across at least two
networks (Testnet and Mainnet) and assert the produced RedeemersKey entries for
RedeemerTag::Reward are in the expected sorted order (scripts vs keys and by
payload hash/network tag). Also include a malformed withdrawal key (invalid
address bytes) and assert mk_plutus_script_redeemer_pointers returns
Err(PostAlonzo(InputDecoding)) rather than panicking. Ensure the test
imports/uses the same helper functions/types (sort_reward_accounts,
mk_plutus_script_redeemer_pointers, StakeAddress, Address, RedeemersKey,
RedeemerTag) so it will catch regressions in both the comparator and the
fallible parsing path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c582712e-dfb0-4c4d-b98a-7ed2212c6069
📒 Files selected for processing (1)
pallas-validate/src/phase1/conway.rs
Summary
mk_plutus_script_redeemer_pointers), so script-locked reward accounts produce aRedeemerTag::Rewardpointer at the correct sorted index..expect()/unreachable!()panics on reward-account decoding withPostAlonzo(InputDecoding)propagation, so a malformed withdrawal in untrusted block/mempool input becomes a validation error rather than a node-level panic.Supersedes #708 — same intent, no panics on adversarial input.
Test plan
cargo build -p pallas-validatecargo clippy -p pallas-validate --all-targets(clean)cargo test -p pallas-validate(all suites pass: alonzo, babbage, byron, conway, shelley_ma)Summary by CodeRabbit
New Features
Bug Fixes