Skip to content

Conversation

Unisay
Copy link
Contributor

@Unisay Unisay commented Sep 18, 2025

Summary

This PR implements cost modeling for Value-related builtins: lookupCoin, valueContains, valueData, and unValueData.

Implementation

Complete cost modeling pipeline:

  • Cost model infrastructure and parameter definitions
  • Benchmarking framework with realistic Cardano constraints
  • Statistical analysis with R models (linear/constant based on performance characteristics)
  • Updated JSON cost model configurations across all versions

Cost models:

  • valueData: Uses constant cost model based on uniform performance analysis
  • lookupCoin: Linear cost model with dimension reduction for 3+ parameters
  • valueContains: Linear cost model for container/contained size dependency
  • unValueData: Linear cost model for size-dependent deserialization

All functions now have proper cost models instead of unimplemented placeholders.

@Unisay Unisay self-assigned this Sep 18, 2025
Copy link
Contributor

github-actions bot commented Sep 18, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://IntersectMBO.github.io/plutus/pr-preview/pr-7344/

Built to branch gh-pages at 2025-09-19 08:01 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@Unisay Unisay force-pushed the yura/costing-builtin-value branch 6 times, most recently from 528ebcd to 69f1d6f Compare September 24, 2025 16:06
@Unisay Unisay changed the title WIP: Add costing for lookupCoin and valueContains builtins Cost models for LookupCoin, ValueContains, ValueData, UnValueData builtins Sep 24, 2025
@Unisay Unisay marked this pull request as ready for review September 24, 2025 16:24
@Unisay
Copy link
Contributor Author

Unisay commented Sep 24, 2025

@Unisay Unisay requested review from kwxm and ana-pantilie September 24, 2025 16:41
Unisay and others added 4 commits September 25, 2025 16:22
Add new benchmarking infrastructure for Value builtin operations:
- Values.hs benchmark module with comprehensive test coverage
- Integration into main benchmarking suite
- Test cases for cost model validation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implement statistical modeling and parameter extraction:
- R models for lookupCoin, valueContains, valueData, unValueData
- Linear regression models with proper memory scaling
- Cost model parameter extraction and conversion infrastructure

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update benchmarking dataset with extensive Value builtin measurements:
- Performance data for lookupCoin, valueContains, valueData, unValueData
- Wide range of input sizes for accurate cost modeling
- Statistical data supporting linear regression models

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replace unimplementedCostingFun with proper parameter-based costing:
- Wire Value builtin cost parameters into evaluation machinery
- Update all cost model configurations (A, B, C) with generated parameters
- Enable accurate gas cost estimation for Value operations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Unisay Unisay force-pushed the yura/costing-builtin-value branch from 30a34e3 to b698ec1 Compare September 25, 2025 14:58
…k sizes

Refactor Value benchmark generators to use Cardano-compliant constraints
and prevent generation of unrealistically large Values that were causing
inflated cost model parameters.

- Fix policy IDs to exactly 28 bytes (MintingPolicyHash size)
- Limit token names to 0-32 bytes per Cardano ledger spec
- Cap random generation to max 10,000 policy/token pairs
- Simplify generator architecture by removing complex layered logic
- Remove unused helper functions and imports
- Apply code quality improvements from HLint suggestions

This addresses the unValueData builtin having an extremely high intercept
cost (10+ billion) due to benchmarking against Values with millions of
entries that would never exist on-chain.
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.

1 participant