Skip to content
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

Add increment functionality to b256 #4787

Closed
wants to merge 4 commits into from
Closed

Add increment functionality to b256 #4787

wants to merge 4 commits into from

Conversation

bitzoic
Copy link
Member

@bitzoic bitzoic commented Jul 11, 2023

Description

There are currently no mathematical operations allowed on a b256 in Sway. This should come with support of fuel-core v0.19.0 but for now we are able to add an increment function now.

This is critical functionality to storage optimizations that are in progress.

  • Adds increment functionality to b256
  • Moves and modifies overflowing add for u64 to the maths library
  • Modifies the u128 and u256 libraries with new overflowing add

Closes #4781

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@bitzoic bitzoic added enhancement New feature or request lib: std Standard library labels Jul 11, 2023
@bitzoic bitzoic requested review from IGI-111 and a team July 11, 2023 10:57
@bitzoic bitzoic self-assigned this Jul 11, 2023
@bitzoic bitzoic linked an issue Jul 11, 2023 that may be closed by this pull request
Copy link
Contributor

@Braqzen Braqzen left a comment

Choose a reason for hiding this comment

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

utACK, mainly approving based on tests

@SwayStar123
Copy link
Collaborator

I dont see any tests for testing that the b256 doesnt overflow

@bitzoic
Copy link
Member Author

bitzoic commented Jul 12, 2023

I dont see any tests for testing that the b256 doesnt overflow

As far as I'm aware there is no #[should_panic] attribute for inline tests yet

@anton-trunov
Copy link
Contributor

@bitzoic You can add it as an end-to-end test, perhaps. Those can expect panics

Copy link
Contributor

@IGI-111 IGI-111 left a comment

Choose a reason for hiding this comment

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

As we discussed, I think that b256 shouldn't have arithmetic operations, and that we should introduce a u256 primitive type instead to support those.

@bitzoic
Copy link
Member Author

bitzoic commented Jul 24, 2023

Closing in favor of #4794

@bitzoic bitzoic closed this Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lib: std Standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add functionality to increment a b256
5 participants