Skip to content

feat(EVM-1178): add point evaluation test vectors#540

Closed
0xVolosnikov wants to merge 1 commit intodevfrom
vv-evm-1178-point-eval-test-vectors
Closed

feat(EVM-1178): add point evaluation test vectors#540
0xVolosnikov wants to merge 1 commit intodevfrom
vv-evm-1178-point-eval-test-vectors

Conversation

@0xVolosnikov
Copy link
Contributor

@0xVolosnikov 0xVolosnikov commented Feb 27, 2026

What ❔

  • Added point-evaluation cost vector tests for valid and invalid inputs.
  • Verified expected ergs/native charging behavior and removed a stale TODO in cost constants.

Why ❔

  • Protects fee-accounting behavior in point evaluation from regressions.
  • Makes expected charging behavior explicit via tests.

Is this a breaking change?

  • Yes
  • No

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted.

@0xVolosnikov 0xVolosnikov changed the title EVM-1178: add point evaluation test vectors feat(EVM-1178): add point evaluation test vectors Feb 27, 2026
@0xVolosnikov 0xVolosnikov marked this pull request as draft February 27, 2026 22:43
@0xVolosnikov 0xVolosnikov requested a review from Copilot February 27, 2026 22:56
@0xVolosnikov 0xVolosnikov marked this pull request as ready for review February 27, 2026 22:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds explicit test vectors to lock in fee-accounting (ERGs/native) and error semantics for the point-evaluation system function, preventing regressions in EVM-1178-related charging behavior.

Changes:

  • Added a cost-vector test harness (assert_cost_vector) and a consolidated valid input fixture for point evaluation.
  • Added test cases covering valid execution and several invalid-input scenarios while asserting constant resource charging.
  • Removed a stale TODO comment related to point-evaluation native cost constants.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
basic_system/src/system_functions/point_evaluation.rs Adds new tests asserting expected outputs/errors and fixed ERGs/native charging across valid/invalid inputs.
basic_system/src/cost_constants.rs Removes an outdated TODO near point-evaluation native cost constant.

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

Comment on lines +220 to +221
assert_cost_vector(
&vec![0u8; 191],
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

&vec![0u8; 191] allocates a Vec just to pass a slice. Consider using a fixed-size byte array/slice (e.g., &[0u8; 191]) or binding the Vec to a local variable before borrowing, to avoid an unnecessary heap allocation in this test.

Suggested change
assert_cost_vector(
&vec![0u8; 191],
let invalid_input_too_short = [0u8; 191];
assert_cost_vector(
&invalid_input_too_short,

Copilot uses AI. Check for mistakes.
Comment on lines +258 to +263
let modulus = [
0x73, 0xed, 0xa7, 0x53, 0x29, 0x9d, 0x7d, 0x48, 0x33, 0x39, 0xd8, 0x08, 0x09, 0xa1,
0xd8, 0x05, 0x53, 0xbd, 0xa4, 0x02, 0xff, 0xfe, 0x5b, 0xfe, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x01,
];
invalid_scalar_z[32..64].copy_from_slice(&modulus);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The BLS12-381 scalar field modulus byte array is duplicated here (and also appears in other tests in this module, e.g. test_point_evaluation_invalid_scalar_z). Consider factoring it into a shared const/helper to avoid divergence if the value ever needs to change or be reused elsewhere.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

Benchmark report

Benchmark Symbol Base Eff Head Eff (%) Base Raw Head Raw (%) Base Blake Head Blake (%) Base Bigint Head Bigint (%)
block_19299001 process_block 315,681,952 315,681,952 (+0.00%) 273,016,552 273,016,552 (+0.00%) 410,630 410,630 (+0.00%) 9,023,830 9,023,830 (+0.00%)
block_22244135 process_block 197,585,908 197,585,908 (+0.00%) 170,670,116 170,670,116 (+0.00%) 172,040 172,040 (+0.00%) 6,040,788 6,040,788 (+0.00%)
precompiles bn254_ecadd 53,268 53,268 (+0.00%) 47,816 47,816 (+0.00%) 0 0 (+0.00%) 1,363 1,363 (+0.00%)
precompiles bn254_ecmul 728,781 728,781 (+0.00%) 564,593 564,593 (+0.00%) 0 0 (+0.00%) 41,047 41,047 (+0.00%)
precompiles bn254_pairing 72,336,733 72,336,733 (+0.00%) 57,808,589 57,808,589 (+0.00%) 0 0 (+0.00%) 3,632,036 3,632,036 (+0.00%)
precompiles ecrecover 479,871 477,141 (-0.57%) 311,099 309,217 (-0.60%) 0 0 (+0.00%) 42,193 41,981 (-0.50%)
precompiles id 927 927 (+0.00%) 927 927 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles keccak 137,579 137,579 (+0.00%) 137,579 137,579 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles modexp 31,267,857 31,267,857 (+0.00%) 20,610,037 20,610,037 (+0.00%) 0 0 (+0.00%) 2,664,455 2,664,455 (+0.00%)
precompiles p256_verify 748,861 748,861 (+0.00%) 470,169 470,169 (+0.00%) 0 0 (+0.00%) 69,673 69,673 (+0.00%)
precompiles point_evaluation 52,918,413 52,918,413 (+0.00%) 40,570,377 40,570,377 (+0.00%) 0 0 (+0.00%) 3,087,009 3,087,009 (+0.00%)
precompiles process_block 147,554,264 147,545,718 (-0.01%) 118,084,772 118,079,030 (-0.00%) 5,160 5,160 (+0.00%) 7,346,733 7,346,032 (-0.01%)
precompiles process_transaction 73,485,914 73,486,891 (+0.00%) 58,790,650 58,791,207 (+0.00%) 160 160 (+0.00%) 3,673,176 3,673,281 (+0.00%)
precompiles ripemd 8,013 8,013 (+0.00%) 8,013 8,013 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles run_tx_loop 146,902,625 146,894,794 (-0.01%) 117,512,813 117,507,786 (-0.00%) 180 180 (+0.00%) 7,346,733 7,346,032 (-0.01%)
precompiles sha256 13,168 13,168 (+0.00%) 13,168 13,168 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles system_init 46,785 46,785 (+0.00%) 46,785 46,785 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles verify_and_apply_batch 146,508 146,480 (-0.02%) 110,188 110,160 (-0.03%) 2,270 2,270 (+0.00%) 0 0 (+0.00%)

@0xVolosnikov
Copy link
Contributor Author

Doesn't actually cover the task

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