-
Notifications
You must be signed in to change notification settings - Fork 108
basic features BigIntOperators module code generator #2216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Contract comparison - from fe3caee to 8242bd0
|
d1e428d to
5e550d9
Compare
Coverage SummaryTotals
FilesExpand
|
18c43fd to
a0e88b2
Compare
| use num_traits::{pow, sign::Signed, Zero}; | ||
| use std::convert::TryInto; | ||
|
|
||
| macro_rules! binary_op_method { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These guys just got moved further below, no changes
There was a problem hiding this comment.
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 introduces a comprehensive code generator tool (op-test-gen) that automatically generates BigInt/BigUint operator tests and the BigIntOperators module for the basic-features contract. The generator creates extensive scenario-based tests to validate all arithmetic, bitwise, and shift operators on big numbers.
Key changes include:
- New
op-test-gentool that generates operator test endpoints and mandos test scenarios - Division by zero error handling added to the Rust VM's BigInt operations (
bi_t_divandbi_t_mod) - Generated test scenarios split into arithmetic, bitwise, and shift operations for better organization
Reviewed changes
Copilot reviewed 16 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/op-test-gen/src/*.rs | New code generator tool with operator definitions, endpoint generation, and scenario creation |
| tools/op-test-gen/Cargo.toml | Package configuration for the code generator tool |
| contracts/feature-tests/basic-features/src/big_num_operators.rs | Auto-generated trait with comprehensive operator endpoints for BigInt/BigUint |
| contracts/feature-tests/basic-features/scenarios/*.scen.json | Auto-generated test scenarios for arithmetic, bitwise, and shift operations |
| contracts/feature-tests/basic-features/tests/*_test.rs | Test files updated with new operator tests; slow tests moved to separate file |
| chain/vm/src/host/vm_hooks/vh_handler/vh_managed_types/vh_big_int.rs | Added division by zero checks and reorganized implementation into multiple impl blocks |
| Cargo.toml | Added op-test-gen tool to workspace members |
| Cargo.lock | Updated with op-test-gen dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_slow_test.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Testing the big number operators using a new suite of mandos tests. These tests are created using a new code generator (they are large).
There is a very similar programmatic test in the Go VM, but that one cannot be used to test the debugger infrastructure/Rust VM.
The same code generator is now generating the
BigIntOperatorsmodule inbasic-features. This makes sure that no operator is left out (they weren't).By running these tests on the Rust VM, we noticed that division by zero was not properly being handled. This is also fixed.
The ultimate point of this PR is to generate the same kind of tests on NonZeroBigUint in a future PR.
NOTE: for some reason the new tests run extremely slowly on wasmer-experimental. In fact, that whole infrastructure is suspiciously slow. For now, the new tests are specifically not run there (only using mx-scenario-go or the debugger, both of which run fast).