Skip to content

Fix user function complexities#2128

Open
alexeykiselev wants to merge 3 commits into
determenistic-finality-featurefrom
fix-user-function-complexities
Open

Fix user function complexities#2128
alexeykiselev wants to merge 3 commits into
determenistic-finality-featurefrom
fix-user-function-complexities

Conversation

@alexeykiselev

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Ride function complexity catalogue (primarily for user/extracted functions across stdlib versions) and adds regression tests plus Ride source fixtures to validate both estimation and evaluation complexity for selected real-world expressions.

Changes:

  • Adjust complexity values for several functions (e.g., data getters / @extrUser(...)) in the generator catalogue for V3/V4/V9.
  • Add new estimation/evaluation tests that compile Ride scripts from pkg/ride/testData and assert expected complexities.
  • Add new Ride scripts documenting and exercising the targeted complexity scenarios across STDLIB versions.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/ride/tree_evaluation_test.go Adds evaluation complexity regression tests for selected Ride scripts.
pkg/ride/tree_estimation.go Minor rename in local variables used to return estimator results.
pkg/ride/tree_estimation_test.go Adds estimation complexity regression tests for selected Ride scripts.
pkg/ride/testData/complexity_v3_get_value_by_index.ride New Ride fixture covering V3 throwing getters (by-index) complexity.
pkg/ride/testData/complexity_v4_get_by_index.ride New Ride fixture covering V4–V8 by-index getter variants complexity.
pkg/ride/testData/complexity_v6_address_from_public_key.ride New Ride fixture covering addressFromPublicKey in V6+.
pkg/ride/testData/complexity_v9_get_by_index.ride New Ride fixture covering V9 by-index getter variants and short-circuiting behavior.
pkg/ride/generate/internal/functions_generation.go Updates generator catalogue values for V3/V4/V9 to match intended complexities.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +6483 to +6486
f, err := os.Open(test.fn)
require.NoError(t, err)
src, err := io.ReadAll(f)
require.NoError(t, err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use t.Cleanup

Comment on lines +697 to +700
f, err := os.Open(test.fn)
require.NoError(t, err)
src, err := io.ReadAll(f)
require.NoError(t, err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here also

Comment on lines +22 to +25
# 4 equality checks: 4 * 1 = 4 and 1 inequality check: 1, 5 in total
# One size call: 1
# Total Estimation Complexity: 16 + 1 + 12 + 4 + 5 + 1 = 39.
# Total Evaluation Complexity: 16 + 1 + 8 + 4 + 5 + 1 = 35.
Comment on lines +8 to +11
# Discrepancy: Scala doc complexity = 1, Go catalogue = 63
# Delta: 63 - 1 = 62 (Go over-estimates by 62 per call)
#
# addressFromPublicKey is called once.
@nickeskov
nickeskov deployed to Deploy-testnet-amd64 July 8, 2026 09:48 — with GitHub Actions Active
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.

3 participants