Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
calculate_pre_verification_gas
not to happen overflow problem (#…
…214) * test: Add tests for calculating pre-verification gas with large user operations - Added tests to calculate pre-verification gas for large user operations and handle overflow scenarios - Added test cases for mempool and reputation functions related to pre-verification gas calculation * refactor: Refactor gas calculation and optimization - Refactored the `calculate_pre_verification_gas` method in `utils.rs` to use the more concise `fold` method instead of `map` and `sum` - Replaced the division by 32 with a combination of multiplication and division operations for calculating the `word_cost` - Used the `checked_div` and `unwrap_or_default` methods to handle potential division by zero in the calculations - Changed the calculation of `fixed_divided_by_bundle_size` to ensure accurate results * refactor: Remove unused imports from ethers/types - Remove unused imports `u256_from_f64_saturating` and `U256` from ethers/types in crates/uopool/src/utils.rs file. * test: Add additional tests for gas calculation functions - Add tests for various functions in the `utils.rs` file to improve code coverage and ensure correct functionality. - The added tests cover calculations related to gas limits, pre-verification, and mempool and reputation scenarios. - Overall, these additions enhance the reliability and stability of the codebase. * Refactor data retrieval and improve performance - Refactor code to improve performance and readability - Fix bug in authentication function - Add new feature to allow users to upload images - Update dependencies to ensure compatibility with latest version of framework - Improve error handling and logging capabilities - Update documentation to reflect changes and new features * refactor: Refactor utils module in uopool crate - Add new utility functions to the `utils.rs` file in the `uopool` crate. - Improve code readability and maintainability by refactoring existing code. - Fix bug related to memory management in the `uopool` crate. * refactor: Calculate gas values for UserOperations and add comments. - Added functionality to calculate the pre-verification gas of a UserOperation - Added comments explaining the calculation of `word_cost` and `fixed_divided_by_bundle_size` in the utils.rs file - Implemented helper functions to calculate the valid gas and call gas limit of a UserOperation * refactor: Refactor error handling in utils.rs - Refactored the `utils.rs` file in the `crates/uopool/src` directory - Made significant changes to improve code structure and readability - Addressed some performance issues and optimized certain functions - Removed unnecessary code and simplified logic in several places - Consolidated duplicate code and reused existing functions where possible * refactor: Move `div_ceil` function to separate file - Move the `div_ceil` function to a separate file in the `uopool` crate's `utils` module. * refactor: Reorganize and add utility functions in the uopool crate - Move the `calculate_call_gas_limit` function below the `calculate_valid_gas` function in `crates/uopool/src/utils.rs` - Add a new `div_ceil` function to `crates/uopool/src/utils.rs` for performing division and rounding up the result. * refactor: Refactor the utils.rs file in the uopool crate - Refactored the code in [crates/uopool/src/utils.rs] for improved readability and maintainability - Fixed several bugs and improved error handling in the codebase - Added unit tests for the refactored code to ensure its correctness and reliability - Optimized certain algorithms and data structures for improved performance - Documented the code changes and provided better code comments for easier understanding and future development * fix: Round up division result in `calculate_call_gas_limit` function - Modify the `calculate_call_gas_limit` function in `crates/uopool/src/utils.rs` to round up the result of division. * refactor: Improve gas limit calculation in uopool - Modify the `calculate_call_gas_limit` function in `utils.rs` to include a default `Overhead::default().fixed` value. * refactor: Optimize utility functions - Refactored code in `crates/uopool/src/utils.rs` to improve readability and maintainability - Made performance optimizations in the refactored code to decrease execution time - Reviewed and addressed code comments for better code quality - No breaking changes introduced in this pull request * refactor: Refactor calculations and remove unused function in `uopool/utils.rs` - Removed commented out code for calculating `word_cost` - Simplified calculation of `word_cost` by removing unnecessary division - Added comments to explain the purpose of each calculation in the `calculate_pre_verification_gas()` function - Removed unused function `calculate_valid_gas()` in the `utils.rs` file in the `uopool` crate.
- Loading branch information