Skip to content

feat(primitives): support multiple Plutus language cost models in script data#763

Merged
scarmuega merged 4 commits into
mainfrom
script-data-multiple-languages
May 8, 2026
Merged

feat(primitives): support multiple Plutus language cost models in script data#763
scarmuega merged 4 commits into
mainfrom
script-data-multiple-languages

Conversation

@scarmuega
Copy link
Copy Markdown
Member

Supersedes #730 — rebased onto current main to resolve a conflict in pallas-primitives/src/conway/script_data.rs with the recent const → static LazyLock clippy fix (a9e538a). Original work and authorship by @nicolasLuduena.

Summary

  • Replace LanguageView(PlutusVersion, CostModel) with LanguageViews(BTreeMap<PlutusVersion, CostModel>) so a single transaction can carry cost models for multiple Plutus versions simultaneously.
  • Update ScriptData to canonically encode the multi-language map (V2/V3 sorted, then V1 last because it CBOR-encodes as 0x4100).
  • Refactor the txbuilder API: StagingTransaction.language_viewlanguage_views; the old .language_view(kind, cm) setter is replaced by .language_views(views) (set whole map) and .add_language(kind, cm) (incremental).
  • Fix pallas-validate::tx_languages so it returns all languages present in a tx (previously dropped V3 when V1+V2+V3 were all in use, and only ever returned the highest single language). cost_model_for_tx now builds a LanguageViews covering every language in the tx.
  • Add test vector test_data/conway9.tx exercising a transaction with all three Plutus versions.

Breaking changes

Public API: LanguageViewLanguageViews; ScriptData.language_viewlanguage_views; StagingTransaction.language_view field and .language_view(...) builder method renamed/replaced as above.

Test plan

  • cargo build --workspace --tests clean
  • cargo test -p pallas-primitives script_data (multi-language hash vector)
  • cargo test -p pallas-txbuilder
  • cargo test -p pallas-validate

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Warning

Rate limit exceeded

@scarmuega has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 25 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b97f313e-cc5f-4296-b629-41e808afe6f3

📥 Commits

Reviewing files that changed from the base of the PR and between b221e35 and ea7d2e3.

📒 Files selected for processing (6)
  • pallas-primitives/src/conway/script_data.rs
  • pallas-txbuilder/src/conway.rs
  • pallas-txbuilder/src/transaction/model.rs
  • pallas-txbuilder/src/transaction/serialise.rs
  • pallas-validate/src/phase1/conway.rs
  • test_data/conway9.tx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch script-data-multiple-languages

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.

@scarmuega scarmuega merged commit 5c25003 into main May 8, 2026
13 of 15 checks passed
@scarmuega scarmuega deleted the script-data-multiple-languages branch May 8, 2026 19:28
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