Skip to content

fix: align cost model key lists with Haskell ParamName enum order#51

Open
jonathanlim222 wants to merge 2 commits into
mainfrom
cost-model-changes
Open

fix: align cost model key lists with Haskell ParamName enum order#51
jonathanlim222 wants to merge 2 commits into
mainfrom
cost-model-changes

Conversation

@jonathanlim222
Copy link
Copy Markdown
Contributor

@jonathanlim222 jonathanlim222 commented May 15, 2026

This PR updates the cost model logic to support the upcoming v11 changes.

  • cost_map.rs: Rewrote V1, V2, and V3 key lists to match the Haskell ParamName enum order exactly — 332/332/350 entries respectively. Removed the incorrect length gates (len == 169, len == 178, len == 297) that were gating ripemd_160 at the wrong positions (166/175 instead of 276–278). Extracted shared PLOMIN_KEYS, PV11_KEYS, BLS12_G1_KEYS, BLS12_G2_KEYS constants to avoid repetition across versions. Fixed a key name bug in V3: "blake2b_224-mem-arguments-slope" → "blake2b_224-mem-arguments".
  • builtin_costs_v1.rs / builtin_costs_v2.rs: initialize() now reads drop_list, length_of_array, list_to_array, and index_array from the cost map rather than using hardcoded values, so PV11 protocol parameters are respected for V1 and V2 scripts.
  • builtin_costs_v3.rs: Fixed the matching "blake2b_224-mem-arguments-slope" key lookup in initialize().
  • Tests: Updated assert_default_cost_model_v1/v2 to use 295-entry vectors with correct PV11 values at positions 284–294. Updated ripemd_160_cost_post_plomin_v1/v2 to use 279-entry vectors reflecting the correct ripemd_160 position (276–278).

@jonathanlim222 jonathanlim222 marked this pull request as ready for review May 15, 2026 20:43
@jonathanlim222 jonathanlim222 requested a review from a team as a code owner May 15, 2026 20:43
Signed-off-by: Jonathan Lim <jonathan.lim.222@gmail.com>
Signed-off-by: Jonathan Lim <jonathan.lim.222@gmail.com>
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