Skip to content

[M-03] - Checked Fixed-Point Helpers Revert on Intermediate I256 Overflow #530

@ozgunozerk

Description

@ozgunozerk
  • checked_mul_div_floor and checked_mul_div_ceil are not returning None for overflows, only for DivisionByZero case. This is because of the internal API we use for i256 provided by soroban_sdk lacks the checked versions of mul, div, rem_euclid, etc.
  • soroban_sdk uses i256_mul, i256_rem_euclid, etc. in their code, which returns a Result. We could use these, and map the type Result into Option, but that was also impossible, because these functions, and their arguments (which require i256Val type) are private, making it impossible us to use them.
  • Even if we could use these internal functions, the DevX of our code will be hindered, since their API is not suited for external use.
  • Best option is, to submit an issue to soroban_sdk repository for this, and wait for them (and help if we can) to expose the checked variants of these above-mentioned functions.
  • When soroban_sdk can expose the checked versions of the mul, div, etc. we can just replace them, and the fix should be complete.

Here is the issue created at soroban_sdk repo: stellar/rs-soroban-sdk#1659

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions